all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: Andreas Schwab <schwab@suse.de>
Cc: Sam Steingold <sds@gnu.org>, emacs-devel@gnu.org
Subject: Re: busyloop in sigchld_handler
Date: Tue, 13 Mar 2007 23:19:19 +0100	[thread overview]
Message-ID: <85abyglrbs.fsf@lola.goethe.zz> (raw)
In-Reply-To: <jey7m1sd8a.fsf@sykes.suse.de> (Andreas Schwab's message of "Tue\, 13 Mar 2007 10\:29\:41 +0100")

Andreas Schwab <schwab@suse.de> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> Andreas Schwab <schwab@suse.de> writes:
>>
>>> David Kastrup <dak@gnu.org> writes:
>>>
>>>> Andreas Schwab <schwab@suse.de> writes:
>>>>
>>>>> If you don't use WNOHANG you open up a race where several processes may
>>>>> have their status changed, but only one signal is sent (non-realtime
>>>>> signals are not queued).
>>>>
>>>> How does WNOHANG protect against that?
>>>
>>> It makes it possible to loop around without blocking.
>>
>> Too bad you snipped the details of my question.  It does not make it
>> possible to loop around without preemption.
>
> What do you mean with "without preemption"?

"Preemption" means the kernel forcibly rescheduling the task.  Since
there is no other way in which the process will either exit the loop
(since that requires some other process to change its status) or yield
the CPU, it will eventually happen.

>> In fact, it _forces_ preemption at some point of time (this is the
>> only way to exit the infinite loop on a single-processor system),
>
> Which inifinite loop?

The one waiting for the demise of a process that gets no processing
time for dying.

>> and when preemption happens, of course several signals may be
>> delivered together: after all, a preempted process is not so likely
>> to get scheduled right again.
>
> I don't understand how preemption comes into play here.

It is the only thing that can prevent a deadlock here.

>>> On system without WNOHANG there needs to be other mechanisms to
>>> garantee one signal per child (they probably redeliver the signal
>>> as long as such children exist).
>>
>> Again: I don't see that this guaranteed one signal per child, and
>> you did not explain how it could.
>
> From POSIX:
>
>  If _POSIX_REALTIME_SIGNALS is defined, and the implementation
>  queues the SIGCHLD signal, then if wait( ) or waitpid ( ) returns
>  because the status of a child process is available, any pending
>  SIGCHLD signal associated with the process ID of the child process
>  shall be discarded.  Any other pending SIGCHLD signals shall remain
>  pending.  Otherwise, if SIGCHLD is blocked, if wait( ) or waitpid (
>  ) return because the status of a child process is available, any
>  pending SIGCHLD signal shall be cleared unless the status of
>  another child process is available.

I can't see how this guarantees one signal per child.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

  reply	other threads:[~2007-03-13 22:19 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-11 18:33 busyloop in sigchld_handler Sam Steingold
2007-03-11 19:39 ` Kim F. Storm
2007-03-11 19:43   ` David Kastrup
2007-03-11 19:51     ` Sam Steingold
2007-03-11 20:42       ` Kim F. Storm
2007-03-11 21:06   ` Sam Steingold
2007-03-11 21:14     ` Eli Zaretskii
2007-03-11 21:17       ` Sam Steingold
2007-03-11 21:51         ` Eli Zaretskii
2007-03-11 22:21           ` Sam Steingold
2007-03-12  4:24             ` Richard Stallman
2007-03-12  7:00               ` David Kastrup
2007-03-13  2:43                 ` Richard Stallman
2007-03-11 22:27     ` Andreas Schwab
2007-03-11 22:30     ` Kim F. Storm
2007-03-12 17:37     ` Andreas Schwab
2007-03-12 17:53       ` Sam Steingold
2007-03-12 18:45         ` Andreas Schwab
2007-03-12 18:57           ` Sam Steingold
2007-03-12 19:28             ` Andreas Schwab
2007-03-12 19:34               ` David Kastrup
2007-03-12 21:36                 ` Andreas Schwab
2007-03-13  7:29                   ` David Kastrup
2007-03-13  9:29                     ` Andreas Schwab
2007-03-13 22:19                       ` David Kastrup [this message]
2007-03-13 22:28                         ` Andreas Schwab
2007-03-13 22:54                           ` David Kastrup
2007-03-13 23:17                             ` Andreas Schwab
2007-03-14  7:06                               ` David Kastrup
2007-03-14  9:24                                 ` Kim F. Storm
2007-03-14 10:00                                   ` David Kastrup
2007-03-14 10:22                                     ` Andreas Schwab
2007-03-14 10:52                                       ` David Kastrup
2007-03-14 11:01                                         ` Andreas Schwab
2007-03-14 11:12                                           ` David Kastrup
2007-03-14 12:29                                             ` Andreas Schwab
2007-03-14 10:01                                   ` Andreas Schwab
2007-03-14 13:15                                     ` Kim F. Storm
2007-03-14 13:41                                       ` Andreas Schwab
2007-03-14 14:10                                         ` Kim F. Storm
2007-03-14 14:12                                           ` Andreas Schwab
2007-03-14 15:02                                             ` Kim F. Storm
2007-03-14 16:34                                               ` Andreas Schwab
2007-03-16  9:34                                                 ` Kim F. Storm
2007-03-16  9:59                                                   ` Andreas Schwab
2007-03-14  3:24                     ` Richard Stallman
2007-03-14 17:34                       ` David Kastrup
2007-03-26  1:47 ` YAMAMOTO Mitsuharu
2007-03-26  2:02   ` Sam Steingold
2007-03-26  2:17     ` YAMAMOTO Mitsuharu
2007-03-28 10:02     ` Kim F. Storm
2007-03-28 15:19       ` Chong Yidong
2007-03-28 15:25         ` Andreas Schwab
2007-03-28 15:33           ` Kim F. Storm
2007-03-28 15:37             ` Andreas Schwab
2007-03-28 20:18               ` Kim F. Storm
2007-03-29 17:59                 ` Richard Stallman
2007-03-28 15:30         ` Alfred M. Szmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85abyglrbs.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=schwab@suse.de \
    --cc=sds@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.