Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: getting the exit value of an exec'd program Message-ID: <3916@auspex.auspex.com> Date: 17 Aug 90 21:11:54 GMT References: <1990Aug15.223952.1175@NCoast.ORG> <12635@hydra.gatech.EDU> Organization: Auspex Systems, Santa Clara Lines: 22 >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....