emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: busyloop in sigchld_handler


From: David Kastrup
Subject: Re: busyloop in sigchld_handler
Date: Sun, 11 Mar 2007 20:43:13 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux)

address@hidden (Kim F. Storm) writes:

> Sam Steingold <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]