How to get Status of processes in C environment

Chris Torek chris at mimsy.umd.edu
Wed Sep 12 17:30:38 AEST 1990


In article <4049 at auspex.auspex.com> guy at auspex.auspex.com (Guy Harris) writes:
>If you just ignore "union wait" (and the "lint" complaints that doing so
>will give you), and treat the "status" argument to "wait()" as an "int
>*", even on BSD systems, your code will still work (unless the
>implementor of your UNIX system screwed up badly), but will be more
>portable and won't be polluted with #ifdefs. 

Right.

Note, in 4.3BSD-reno the argument to wait (and wait3) has been changed
back to `int *'.  The W* macros in <sys/wait.h> operate on `int' lvalues
(and continue to work on `union wait's by the bletcherous hack of
defining the W* macros as, e.g.,

	#define _W_INT(w)	(*(int *)&(w))
	#define	WEXITSTATUS(x)	(_W_INT(x) >> 8)

The funny _W_INT definition WILL GO AWAY someday, along with `union wait'.)
If compiling with the (semi-nonexistent) `POSIX compiler', the W* macros
operate on int expressions (because _W_INT(w) is defined is (w)).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list