getting the exit value of an exec'd program
Guy Harris
guy at auspex.auspex.com
Sat Aug 18 07:11:54 AEST 1990
>Its man page describes the union wait status variable
>returned by wait(2) and its variants. (Exact return type also varies
>between wait() variants and diff. unices.)
Don't waste time with "union wait". BSD isn't *really* different from
other UNIX variants; "wait" *really* fills in an "int", not a "union
wait *". (If you don't believe me, check out the kernel code that
implements "wait" - it fills in "u_rval2", which is an "int", with the
exit status.) "union wait" is just a hack that gives the individual
bits of the "int" individual names; unfortunately, it does that with bit
fields, which are C-implementation-dependent, while the actual bits are
C-implementation-*in*dependent.
If you write code not using "union wait", it'll work just fine on BSD
systems - and even pass "lint" in 4.4BSD, although not in earlier
releases, because POSIX says it's an "int", period. It'll also work on
systems that lack "union wait", e.g. vanilla S5 (at least prior to S5R4;
they may have stuck in "/usr/ucbinclude/sys/wait.h" in S5R4 to make it
easier to recompile BSD programs). If you write code using "union
wait", and make it generally available, somebody'll probably try porting
it to S5 and have one more porting obstacle to deal with before it
works....
More information about the Comp.unix.questions
mailing list