Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!sri-spam!sri-unix!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: exit(-1), 0 is sometimes magic Summary: oops, thanks Keywords: exit, zero, shells Message-ID: <567@cresswell.quintus.UUCP> Date: 23 Jan 88 10:16:11 GMT References: <502@cresswell.quintus.UUCP> <6935@brl-smoke.ARPA> <1179@wjvax.UUCP> <39799@sun.uucp> Organization: Quintus Computer Systems, Mountain View, CA Lines: 28 In article <39799@sun.uucp>, guy@gorodish.Sun.COM (Guy Harris) writes: > > Beware, by the way. Due to byte sex problems, even in UNIX, the > > result of system() may be shifted left by 8 (it is on a SUN). > > Nope. This has nothing to do with byte sex problems, and is true on all > non-broken UNIX implementations (even those with a byte size other than 8 > bits). > OOPS! I was misled by the SUN manual page for system(2), which suggests that the value IS e.g. 127 but 'may be displayed as "32512"'. The manual page for wait(2) is still misleading. I checked a System Vr2 manual, and it says "the <> of status contain the low order 8 bits of the argument that the child process passed to exit()"; you have to read carefully to realise that this means the high order 8 bits of the low order 16 bits... I've been using #define WAIT_EXIT(x) (((x) >> 8) & 0377) #define WAIT_DUMP(x) ( (x) & 0200) #define WAIT_SGNO(x) ( (x) & 0177) int child; int status; ... if ((child = wait(&status)) < 0) ... for years, and just put up with 4.2BSD lint complaining about the way I use wait(). I'd forgotten what the macros do. (That's portability...)