NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: standards/51024 (NetBSD misses the mandatory waitid() syscall)
The following reply was made to PR standards/51024; it has been noted by GNATS.
From: Joerg Schilling <Joerg.Schilling%fokus.fraunhofer.de@localhost>
To: <wiz%netbsd.org@localhost>, <standards-manager%netbsd.org@localhost>, <netbsd-bugs%netbsd.org@localhost>,
<gnats-bugs%netbsd.org@localhost>, <gnats-admin%netbsd.org@localhost>,
<christos%zoulas.com@localhost>
Cc:
Subject: Re: standards/51024 (NetBSD misses the mandatory waitid() syscall)
Date: Mon, 4 Apr 2016 17:49:34 +0200
Christos Zoulas <christos%zoulas.com@localhost> wrote:
> On Apr 4, 10:08am, christos%zoulas.com@localhost (Christos Zoulas) wrote:
> -- Subject: Re: standards/51024 (NetBSD misses the mandatory waitid() syscall
>
> | Do you have the reference where it says it needs to preserve all 32 bits
> | of exit code? I have not found one.
>
> The reason I am asking all this is because although FreeBSD has made the
> change to pass all 32 bits in this particular instance, they have overloaded
> the meaning of si_status, so that now the user code needs to understand
> what context we are in to interpret it properly. I.e.
>
> - it could be a full 32 bit exit code
> - it could be a signal number
> - it could be a composite 'wait status' (as it is always now with NetBSD,
> except in the waitid case...).
Does the last apply to the signal handler for SIGCHLD only?
It is wrong in any case. Only the first two cases are correct.
> kern_exit.c: siginfo->si_status = WTERMSIG(p->p_xsig);
> kern_exit.c: siginfo->si_status = WTERMSIG(p->p_xsig);
> kern_exit.c: siginfo->si_status = p->p_xexit;
> kern_exit.c: siginfo->si_status = p->p_xsig;
> kern_exit.c: siginfo->si_status = p->p_xsig;
> kern_exit.c: siginfo->si_status = SIGCONT;
> kern_sig.c: p->p_ksi->ksi_status = status;
Thank you for this hint, it seems that I would need to check FreeBSD.
Fortunately I have access to an installation with a recent version.
si_status holds the exit() parameter in case of a normal exit (CLD_EXITED).
It holds the signal number in case the child has been terminated as a result of
a signal: CLD_DUMPED, CLD_KILLED, CLD_TRAPPED, CLD_STOPPED.
In case of CLD_CONTINUED, the status is 0.
So in general: si_status either contains the exit code or a signal number.
See the waitid() emulation in sh/jobs.c. The exit code of course cannot be
retrieved from the historical wait() status value as this only holds the low 8
bits. What you can see from the emulation code in sh/jobs.c is what is expected
to be under what condition in si_code.
If you ever implement more than 255 signals, WTERMSIG() will not work as well.
Jörg
--
EMail:joerg%schily.net@localhost (home) Jörg Schilling D-13353 Berlin
joerg.schilling%fokus.fraunhofer.de@localhost (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.org/private/ http://sourceforge.net/projects/schilytools/files/'
Home |
Main Index |
Thread Index |
Old Index