From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#63865: 29.0.90; call-process while owning the X selection hangs other processes Date: Sat, 03 Jun 2023 08:30:57 -0400 Message-ID: References: <83edmt9j8i.fsf@gnu.org> <87bkhxnhpk.fsf@yahoo.com> <87wn0kn3zu.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21485"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 63865@debbugs.gnu.org To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 03 14:32:29 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q5QQn-0005M8-BE for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Jun 2023 14:32:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5QQR-0003qG-4b; Sat, 03 Jun 2023 08:32:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q5QQN-0003pz-Af for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 08:32:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q5QQM-0007T9-Pr for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 08:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q5QQM-0000m2-CX for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 08:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Jun 2023 12:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63865 X-GNU-PR-Package: emacs Original-Received: via spool by 63865-submit@debbugs.gnu.org id=B63865.16857954682901 (code B ref 63865); Sat, 03 Jun 2023 12:32:02 +0000 Original-Received: (at 63865) by debbugs.gnu.org; 3 Jun 2023 12:31:08 +0000 Original-Received: from localhost ([127.0.0.1]:41769 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5QPT-0000ki-Ji for submit@debbugs.gnu.org; Sat, 03 Jun 2023 08:31:08 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:37639) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5QPP-0000k3-0n for 63865@debbugs.gnu.org; Sat, 03 Jun 2023 08:31:06 -0400 In-Reply-To: <87wn0kn3zu.fsf@yahoo.com> (Po Lu's message of "Sat, 03 Jun 2023 20:07:33 +0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:262828 Archived-At: Po Lu writes: > Spencer Baugh writes: > >> Po Lu writes: >> >>> Eli Zaretskii writes: >>> >>>>> From: Spencer Baugh >>>>> Date: Fri, 02 Jun 2023 21:55:09 -0400 >>>>> >>>>> >>>>> 1. Under X11, with the GTK or Lucid toolkits: >>>>> emacs -Q >>>>> 2. Become owner of the clipboard selection by killing some text; the >>>>> starting comments in the scratch buffer are a good candidate. >>>>> 3. Immediately afterwards (i.e. without copy and pasting text in another >>>>> window), run: >>>>> (call-process "sleep" nil nil nil "inf") >>>>> 4. Now other applications will hang when they attempt to paste text. >>>>> Google Chrome and Slack are two examples. (GTK-based applications >>>>> seem to be fine. So much for proprietary software...) >>>> >>>> Thanks. >>>> >>>> Does this happen also with the latest pretest, v29.0.91? >>> >>> I can't reproduce this, but the closest thing to Google Chrome on the >>> computer I am currently using is Firefox 10.0.7. >> >> BTW, this can also be reproduced using just Emacs. If I try to paste in >> another Emacs instead of in Google Chrome, I get a hang, followed by: >> >> gui-get-selection: (error "Timed out waiting for reply from selection owner") > > Emacs doesn't hang... Well, it hangs for 10 seconds, then times out, because Emacs is correctly implemented. Some other applications are incorrectly implemented and never time out. >> With -DTRACE_SELECTION on both Emacsen, the selection-owner Emacs prints >> no logs, while the pasting Emacs prints the following log: >> >> 48866: Get selection UTF8_STRING, type _EMACS_TMP_ >> 48866: Start waiting 5 secs for SelectionNotify. >> 48866: Waiting for 0 nsecs in addition. >> 48866: Got event = NO >> 48866: Get selection TIMESTAMP, type _EMACS_TMP_ >> 48866: Start waiting 5 secs for SelectionNotify. >> 48866: Waiting for 0 nsecs in addition. >> 48866: Got event = NO >> >>> So would you also build Emacs with -DTRACE_SELECTION, and show what is >>> printed by Emacs when the requestor hangs? >> >> Emacs prints nothing while stuck in call-process and the requestor >> (Chrome) is hanging. > > OK, but then this is not a bug: Emacs can not respond to selection > requests when it is not reading keyboard input. "Emacs can not respond to selection requests when it is not reading keyboard input." sounds like a bug to me! Even if it's hard to fix, it's still a bug. If I'm implementing some package and I decide to use call-process for some long operation, then some user uses my package and it runs call-process, and they get bored while waiting and switch away from Emacs, they'll experience a hang in some other application. That hang seems clearly undesirable! (I should mention that Slack (and possibly all Electron applications) have worse behavior than I originally said: They don't just hang on paste, their UI hangs completely while Emacs is in call-process. (I guess these applications are constantly requesting the selection or something?) Which is an extremely bad experience for the users of packages which use call-process...) I'm personally working around this by replacing call-process with start-process and accept-process-output. Because otherwise my packages (and any other package using call-process ever) will cause random hangs in other applications, which is obviously bad and not something anyone would want. So perhaps call-process on Unix should be reimplemented in terms of those functions? Or if that would change behavior too much, perhaps call-process should be deprecated in favor of some new helper built on those?