From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: busyloop in sigchld_handler Date: Sun, 11 Mar 2007 20:43:13 +0100 Message-ID: <85fy8bpnvy.fsf@lola.goethe.zz> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1173642221 4606 80.91.229.12 (11 Mar 2007 19:43:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 11 Mar 2007 19:43:41 +0000 (UTC) Cc: emacs-devel@gnu.org To: storm@cua.dk (Kim F. Storm) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 11 20:43:32 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HQTx6-0003ID-5T for ged-emacs-devel@m.gmane.org; Sun, 11 Mar 2007 20:43:32 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HQTxf-0005eR-FN for ged-emacs-devel@m.gmane.org; Sun, 11 Mar 2007 14:44:07 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HQTxU-0005eM-AN for emacs-devel@gnu.org; Sun, 11 Mar 2007 15:43:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HQTxR-0005e9-Qp for emacs-devel@gnu.org; Sun, 11 Mar 2007 15:43:55 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HQTxR-0005e6-LT for emacs-devel@gnu.org; Sun, 11 Mar 2007 14:43:53 -0500 Original-Received: from mail-in-04.arcor-online.net ([151.189.21.44]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HQTwr-0005ta-7x for emacs-devel@gnu.org; Sun, 11 Mar 2007 15:43:17 -0400 Original-Received: from mail-in-04-z2.arcor-online.net (mail-in-04-z2.arcor-online.net [151.189.8.16]) by mail-in-04.arcor-online.net (Postfix) with ESMTP id C6A96278950; Sun, 11 Mar 2007 20:43:15 +0100 (CET) Original-Received: from mail-in-05.arcor-online.net (mail-in-05.arcor-online.net [151.189.21.45]) by mail-in-04-z2.arcor-online.net (Postfix) with ESMTP id BB624ABF1E; Sun, 11 Mar 2007 20:43:15 +0100 (CET) Original-Received: from lola.goethe.zz (dslb-084-061-021-177.pools.arcor-ip.net [84.61.21.177]) by mail-in-05.arcor-online.net (Postfix) with ESMTP id 945E212F3DD; Sun, 11 Mar 2007 20:43:15 +0100 (CET) Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id 532E51C4F93F; Sun, 11 Mar 2007 20:43:13 +0100 (CET) In-Reply-To: (Kim F. Storm's message of "Sun\, 11 Mar 2007 20\:39\:25 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux) X-detected-kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:67725 Archived-At: storm@cua.dk (Kim F. Storm) writes: > Sam Steingold writes: > >> GNU Emacs 22.0.95.2 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of >> 2007-03-11 on loiso >> >> I have been observing the following behavior: >> emacs hangs in sigchld_handler waiting for the child process to >> terminate: >> >> do >> { >> errno = 0; >> pid = wait3 (&w, WNOHANG | WUNTRACED, 0); >> } >> while (pid < 0 && errno == EINTR); > >> I fixed the problem with the following patch: > > Absolutely brilliant! I can confirm that it works. > > But can you explain why it works? > And why the problem primarily hit M-x compile. > > Does the fix cause a 1 second delay for other sub-processes ? > >> >> Index: process.c >> =================================================================== >> RCS file: /sources/emacs/emacs/src/process.c,v >> retrieving revision 1.500 >> retrieving revision 1.501 >> diff -u -w -u -b -w -i -B -r1.500 -r1.501 >> --- process.c 1 Mar 2007 10:17:41 -0000 1.500 >> +++ process.c 11 Mar 2007 18:16:50 -0000 1.501 >> @@ -6497,6 +6497,7 @@ >> /* Keep trying to get a status until we get a definitive result. */ >> do >> { >> + sleep (1); >> errno = 0; >> pid = wait3 (&w, WNOHANG | WUNTRACED, 0); >> } > Wouldn't it make more sense to do for (;;) { errno = 0; pid = wait3(&w, WNOHANG | WUNTRACD, 0); if (!(pid < 0 && errno == EINTR)) break; sleep(1); } That way, we don't get an obligatory sleep if things happen to work without it. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum