Messages in this thread |  | | From | Mark.Hemment@uniplex ... | Date | Tue, 4 Jun 96 18:20:12 +0100 | Subject | Re: On SIGCHLD signal semantics |
| |
> Marc La-France wrote;
>> On Tue, 4 Jun 1996 Mark.Hemment@Uniplex.Co.UK wrote: >> wait(2) should fail if a process has no existing unwaited-for child >> processes. errno should be set to ECHILD. The parent shouldn't get >> confused if it is written correctly. >> This is traditional behaviour; I'm sure POSIX.2 hasn't broken it :(
> What you say is true, but only if the parent isn't ignoring SIGCHLD > or the child exits before the parent waits. Thus there's a timing > problem when the parent's SIGCHLD handler is SIG_IGN.
What I say is true - no ifs :) Doesn't matter about the setting of SIGCLD: SIG_IGN, SIG_DFL,... If there are no existing unwaited-for childern, you get ECHILD. Full-stop.
At times I have used setting SIGCLD to SIG_IGN, and called wait(2). This does have a specified action. While there are child processes, wait(2) will not return. When all childern have died, wait(2) returns with ECHILD. This is a useful, and is (possibly) a POSIX.2 requirement.
Of course, if process are unknowning inheriting SIGCLD as SIG_IGN, and using wait(2), they will be getting confused.
There is another 'strangness' with wait(2). If SIGCLD is blocked, then wait(2) doesn't recognise the death of child processes (but does it does return if there was a zombie when it was called). Its tradition....
markhe
|  |