From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Taylor R Campbell Newsgroups: gmane.emacs.bugs Subject: bug#9488: 23.2; `call-process' races with SIGCHLD handler Date: Mon, 12 Sep 2011 20:14:11 +0000 Message-ID: <20110912201804.19D3EE4057@pluto.mumble.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1315859223 4034 80.91.229.12 (12 Sep 2011 20:27:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 12 Sep 2011 20:27:03 +0000 (UTC) To: 9488@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 12 22:26:57 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R3D5k-00046z-2S for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Sep 2011 22:26:56 +0200 Original-Received: from localhost ([::1]:33389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3D5j-0001Ez-J7 for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Sep 2011 16:26:55 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:51125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3D2b-0007wZ-DU for bug-gnu-emacs@gnu.org; Mon, 12 Sep 2011 16:23:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3D2a-00073t-1w for bug-gnu-emacs@gnu.org; Mon, 12 Sep 2011 16:23:41 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3D2Z-00073n-Rp for bug-gnu-emacs@gnu.org; Mon, 12 Sep 2011 16:23:39 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1R3D6o-00066Q-BV; Mon, 12 Sep 2011 16:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Taylor R Campbell Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Sep 2011 20:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 9488 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.131585924523411 (code B ref -1); Mon, 12 Sep 2011 20:28:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Sep 2011 20:27:25 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R3D6C-00065X-LH for submit@debbugs.gnu.org; Mon, 12 Sep 2011 16:27:25 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R3D1Y-0005yy-9R for submit@debbugs.gnu.org; Mon, 12 Sep 2011 16:22:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3CxH-0005nH-36 for submit@debbugs.gnu.org; Mon, 12 Sep 2011 16:18:13 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:34370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3CxH-0005nD-1h for submit@debbugs.gnu.org; Mon, 12 Sep 2011 16:18:11 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:41839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3CxG-0005mo-3j for bug-gnu-emacs@gnu.org; Mon, 12 Sep 2011 16:18:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3CxE-0005mj-QC for bug-gnu-emacs@gnu.org; Mon, 12 Sep 2011 16:18:10 -0400 Original-Received: from pluto.mumble.net ([206.123.75.20]:42164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3CxE-0005mG-Ke for bug-gnu-emacs@gnu.org; Mon, 12 Sep 2011 16:18:08 -0400 Original-Received: by pluto.mumble.net (Postfix, from userid 1014) id 19D3EE4057; Mon, 12 Sep 2011 20:18:04 +0000 (UTC) User-Agent: IMAIL/1.21; Edwin/3.116; MIT-Scheme/9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Mon, 12 Sep 2011 16:27:24 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 12 Sep 2011 16:28:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 140.186.70.43 X-Mailman-Approved-At: Mon, 12 Sep 2011 16:26:54 -0400 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:51076 Archived-At: `call-process' relies on `wait_for_termination' to block until the SIGCHLD handler has run for the synchronous subprocess. But this is not the condition that `wait_for_termination' guarantees on exit. Rather, if `wait_for_termination' returns, then either (a) there is no process having the same pid as the child had, or (b) a SIGCHLD has been delivered. If the subprocess has died, but no SIGCHLD has been delivered yet, then `wait_for_termination' may return even though the SIGCHLD handler has yet to run. As an aside, these conditions are not sufficient for `wait_for_termination' to return: it may block indefinitely if the operating system has already delivered SIGCHLD and reused the pid before control enters `wait_for_termination'. I have not observed indefinite blocking behaviour in practice, but only because pids don't get reused very fast. What I have observed is process exit values of 0 that should have been nonzero on GNU Emacs 23.2.1 (i386--netbsdelf, X toolkit) of 2011-03-02. I noticed this because `M-x grep' sometimes prompts me with `grep -nH' and sometimes with `grep -nH -e', in turn because (call-process "grep" nil nil nil "-e" "/dev/null") sometimes returns 0 and sometimes returns 1 depending on who wins the race. I have not tested newer versions of GNU Emacs, but a cursory glance at the code suggests that while the relevant subprocess code has grown more unmaintainably complicated, the problem persists.