From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Markus Triska Newsgroups: gmane.emacs.bugs Subject: bug#63078: 26.1; Sentinels are sometimes unexpectedly only invoked in script mode Date: Wed, 26 Apr 2023 19:58:54 +0200 Message-ID: <87r0s6frtt.fsf@metalevel.at> References: <87wn1zpn8n.fsf@metalevel.at> <837ctzuprp.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22578"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 63078@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 26 20:00:20 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 1prjRE-0005jX-KL for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 26 Apr 2023 20:00:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prjR5-0006yp-3x; Wed, 26 Apr 2023 14:00:11 -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 1prjQx-0006yW-7l for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2023 14:00:09 -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 1prjQw-0006IH-SJ for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2023 14:00:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1prjQw-0003UG-AE for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2023 14:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Markus Triska Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Apr 2023 18:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63078 X-GNU-PR-Package: emacs Original-Received: via spool by 63078-submit@debbugs.gnu.org id=B63078.168253195413307 (code B ref 63078); Wed, 26 Apr 2023 18:00:02 +0000 Original-Received: (at 63078) by debbugs.gnu.org; 26 Apr 2023 17:59:14 +0000 Original-Received: from localhost ([127.0.0.1]:56947 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prjQ8-0003SX-Dx for submit@debbugs.gnu.org; Wed, 26 Apr 2023 13:59:14 -0400 Original-Received: from [78.47.144.35] (port=55342 helo=metalevel.at) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prjPr-0003Rp-R5 for 63078@debbugs.gnu.org; Wed, 26 Apr 2023 13:59:10 -0400 Original-Received: by metalevel.at (Postfix, from userid 1000) id 8595B9C75F; Wed, 26 Apr 2023 19:58:54 +0200 (CEST) In-Reply-To: <837ctzuprp.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 26 Apr 2023 09:22:02 +0300") 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:260686 Archived-At: Eli Zaretskii writes: > I cannot reproduce the problem with Emacs 28.2: I get "process said: > hello" in the echo-area, as expected. Did you try with the -nw > command-line switch, and if you do, does it change anything? > It could be some timing problem: you start a program that exits almost > immediately, so there could be some race condition between the program > and your code. I can reproduce the problem also with Emacs 28.8, and yes, I also believe this may be a timing issue: I have now constructed a test case that exhibits the issue also when the "-nw" option is used. To reproduce, please start Emacs with: $ emacs -Q or with: $ emacs -Q -nw and then place the forms below in a buffer, and then evaluate the buffer contents with M-x eval-buffer RET. The bash shell is used as external process, the sample C program I originally included is no longer needed. > The expected output of the forms below is an endless stream of messages of the form: trying to elicit race condition at (25673 25753 287220 854000) process status is: run [2 times] process said: hi failed trying to elicit race condition at (25673 25753 289270 703000) process status is: run [2 times] process said: hi failed i.e., the expected case is that *no* race condition exists, and therefore eliciting the issue *fails*, which is the desired result as long as the program runs. However, after I few seconds, this expected sequence of messages stops, and only the following message is then emitted over and over: process status is: exit When this occurs, it means that the sentinel was unexpectedly not invoked when the process stops, in contrast to all preceding cases where the sentinel was invoked as expected when the process terminates. Running the program in script mode yields the expected result over and over, I cannot elicit the issue with the --script option of Emacs. I hope this helps. Can you reproduce the issue with this example? Thank you and all the best, Markus (defvar p-stopped nil) (defun my-sentinel (proc str) (when (string-match "^\\(?:finished\n\\|exited abnormally\\|killed\n\\)" str) (setq p-stopped t))) (defun wait-for-process-end (proc) (while (not p-stopped) (message "process status is: %s" (process-status proc)) (accept-process-output proc 0.1 nil t))) (defun elicit-issue () (with-temp-buffer (let ((proc (start-process "p" (current-buffer) "bash" "-c" "echo -n hi"))) (setq p-stopped nil) (set-process-sentinel proc 'my-sentinel) (wait-for-process-end proc)) (message "process said: %s" (buffer-string)))) (while t (message "trying to elicit race condition at %s" (current-time)) (elicit-issue) (message "failed"))