wait() function survey
Ben Lindstrom
mouring at pconline.com
Mon Aug 28 07:48:27 EST 2000
On Sat, 26 Aug 2000, Damien Miller wrote:
> On Fri, 25 Aug 2000, Ben Lindstrom wrote:
>
> >
> > In serverloop.c we have two wait() lines.
> >
> > POSIX defines wait() was "pid_t wait(int *status)". However older BSD
> > systems could have "int wait(union wait *statusp)" as it's defines.
> >
> > I'm interested to see how many platforms OpenSSH is ported requires the
> > latter define.
> >
> > I know NeXT does.
>
> What is the definition of the union? Is it a fatal error or just a
> warning if the (int*) version is used?
>
It's just a warning if (int*) is used. The reason why I've not looked to
closely at it until recently.
As for the definition of "unit wait" .. <cough> Massively different.
Another nasty thing that NeXT did (unless you defined -posix and use the
libposix.a library.. Maybe I should beg for libposix.a code from Apple
in BSD licensing form =).
As tempting as it is just to implement wait() based on wait4() like
OpenBSD.. wait4() uses the same union structure. Which makes my
waitpid() implement also incorrect (since I was not closely look at
structure differences. <sigh>)
union wait {
int w_status; /* used in syscall */
/*
* Terminated process status.
*/
struct {
#if __BIG_ENDIAN__
unsigned short w_PAD16;
unsigned w_Retcode:8; /* exit code if w_termsig==0 */
unsigned w_Coredump:1; /* core dump indicator */
unsigned w_Termsig:7; /* termination signal */
#else __BIG_ENDIAN__
unsigned short w_Termsig:7; /* termination signal */
unsigned short w_Coredump:1; /* core dump indicator */
unsigned short w_Retcode:8; /* exit code if
w_termsig==0 */
#endif __BIG_ENDIAN__
} w_T;
/*
* Stopped process status. Returned
* only for traced children unless requested
* with the WUNTRACED option bit.
*/
struct {
#if __BIG_ENDIAN__
unsigned short w_PAD16;
unsigned w_Stopsig:8; /* signal that stopped us*/
unsigned w_Stopval:8; /* == W_STOPPED if stopped*/
#else __BIG_ENDIAN__
unsigned short w_Stopval:8; /* == W_STOPPED if stopped*/
unsigned short w_Stopsig:8; /* signal that stopped us*/
#endif __BIG_ENDIAN__
} w_S;
};
More information about the openssh-unix-dev
mailing list