[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: busyloop in sigchld_handler
From: |
Kim F. Storm |
Subject: |
Re: busyloop in sigchld_handler |
Date: |
Sun, 11 Mar 2007 23:30:35 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux) |
Sam Steingold <address@hidden> writes:
> The following message is a courtesy copy of an article
> that has been posted to gmane.emacs.devel as well.
>
>> * Kim F. Storm <address@hidden> [2007-03-11 20:39:25 +0100]:
>>
>> Sam Steingold <address@hidden> writes:
>>
>> Absolutely brilliant! I can confirm that it works.
>
> Thanks!
Actually, I'm not quite sure your patch works.
It seems the unresponsiveness is just delayed some seconds -- at
least sometimes.
I don't know what the system is doing -- flushing the buffer
cache or some such?
GNU Emacs 22.0.95.13 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
Linux kernel: 2.4.20-8
>
>> But can you explain why it works?
>
> wait3 is a system call, which, when invoked in a loop, prevents the
> kernel from doing anything else (in this case, sending SIGCHLD to
> emacs). sleep allows the kernel some time to pass the signal.
>
I tried to verify that there is a loop, but I can't.
Apply the patch below, start emacs -Q, run M-x compile, and look at
sigchld_pid array. I get this:
(gdb) p sigchld_count
$1 = 2
(gdb) p sigchld_sleep
$2 = 8
(gdb) p sigchld_pid
$3 = {1173651414, 0, 5453, 0, 1173651414, 0, -1, 10, 0 <repeats 12 times>}
So I'm puzzled what's going on.
*** process.c 11 Mar 2007 20:32:23 +0100 1.501
--- process.c 11 Mar 2007 23:24:08 +0100
***************
*** 6468,6473 ****
--- 6468,6478 ----
indirectly; if it does, that is a bug */
#ifdef SIGCHLD
+
+ long sigchld_pid[20];
+ int sigchld_count = 0;
+ int sigchld_sleep = 0;
+
SIGTYPE
sigchld_handler (signo)
int signo;
***************
*** 6495,6505 ****
#define WUNTRACED 0
#endif /* no WUNTRACED */
/* Keep trying to get a status until we get a definitive result. */
do
{
! sleep (1);
errno = 0;
pid = wait3 (&w, WNOHANG | WUNTRACED, 0);
}
while (pid < 0 && errno == EINTR);
--- 6500,6522 ----
#define WUNTRACED 0
#endif /* no WUNTRACED */
/* Keep trying to get a status until we get a definitive result. */
+
+ sigchld_count++;
do
{
! unsigned long t1, t2;
! /* sleep (1); */
! time(&t1);
errno = 0;
pid = wait3 (&w, WNOHANG | WUNTRACED, 0);
+ if (sigchld_sleep < 15)
+ {
+ time(&t2);
+ sigchld_pid[sigchld_sleep++] = t1;
+ sigchld_pid[sigchld_sleep++] = t2 - t1;
+ sigchld_pid[sigchld_sleep++] = pid;
+ sigchld_pid[sigchld_sleep++] = errno;
+ }
}
while (pid < 0 && errno == EINTR);
--
Kim F. Storm <address@hidden> http://www.cua.dk
- Re: busyloop in sigchld_handler, (continued)
- Re: busyloop in sigchld_handler, Sam Steingold, 2007/03/11
- Re: busyloop in sigchld_handler, Eli Zaretskii, 2007/03/11
- Re: busyloop in sigchld_handler, Sam Steingold, 2007/03/11
- Re: busyloop in sigchld_handler, Eli Zaretskii, 2007/03/11
- Re: busyloop in sigchld_handler, Sam Steingold, 2007/03/11
- Re: busyloop in sigchld_handler, Richard Stallman, 2007/03/12
- Re: busyloop in sigchld_handler, David Kastrup, 2007/03/12
- Re: busyloop in sigchld_handler, Richard Stallman, 2007/03/12
- Re: busyloop in sigchld_handler, Andreas Schwab, 2007/03/11
- Re: busyloop in sigchld_handler,
Kim F. Storm <=
- Re: busyloop in sigchld_handler, Andreas Schwab, 2007/03/12
- Re: busyloop in sigchld_handler, Sam Steingold, 2007/03/12
- Re: busyloop in sigchld_handler, Andreas Schwab, 2007/03/12
- Re: busyloop in sigchld_handler, Sam Steingold, 2007/03/12
- Re: busyloop in sigchld_handler, Andreas Schwab, 2007/03/12
- Re: busyloop in sigchld_handler, David Kastrup, 2007/03/12
- Re: busyloop in sigchld_handler, Andreas Schwab, 2007/03/12
- Re: busyloop in sigchld_handler, David Kastrup, 2007/03/13
- Re: busyloop in sigchld_handler, Andreas Schwab, 2007/03/13
- Re: busyloop in sigchld_handler, David Kastrup, 2007/03/13