emacs-devel
[Top][All Lists]
Advanced

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

Re: busyloop in sigchld_handler


From: Andreas Schwab
Subject: Re: busyloop in sigchld_handler
Date: Tue, 13 Mar 2007 10:29:41 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux)

David Kastrup <address@hidden> writes:

> Andreas Schwab <address@hidden> writes:
>
>> David Kastrup <address@hidden> writes:
>>
>>> Andreas Schwab <address@hidden> 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"?

> 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?

> 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.

>> 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.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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