home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!cs.utexas.edu!uwm.edu!daffy!spock.cs.wisc.edu!quale
- From: quale@spock.cs.wisc.edu (Doug Quale)
- Subject: Re: union wait
- Message-ID: <1992Nov22.035031.24640@daffy.cs.wisc.edu>
- Sender: news@daffy.cs.wisc.edu (The News)
- Organization: Undergraduate Projects Lab, UW-Madison
- References: <Mf35FIC00YUnR=rW82@andrew.cmu.edu> <1992Nov20.193111.995@serval.net.wsu.edu> <kenc.722383317@sol>
- Date: Sun, 22 Nov 1992 03:50:31 GMT
- Lines: 80
-
- In article <kenc.722383317@sol> kenc@sol.acs.unt.edu (Ken Corey - Operator) writes:
- >hlu@eecs.wsu.edu (H.J. Lu) writes:
- >
- >>Include <sys/wait.h>, You are home free. If your software ueses "union wait"
- >>directly, rather than wait macros, fix your software. That will make it
- >>more portable.
- >
- >
- >Don't forget, <wait.h> defines the union wait structure as an 'int *'.
- >Simply search and replace using your favorite editor, and things should work
- >out just fine. At least *i*'ve gotten good results...your mileage may vary.
- >
-
- I probably *really* shouldn't post this, since this hasn't been well
- tested or even thought out, but
-
- John T. Kohl (I hope I remembered his name correctly, apologies if I
- goofed, he is now active in 386BSD) did a port of BSD make (pmake) to
- Linux in the early days. It was binary only (he would provide source
- to those who asked, but I was too lazy). BSD make makes the most
- egregious use of union wait I can imagine -- it uses the structure
- elements as lvalues (it assigns to them). The code is full of
- statements such as
-
- status.w_retcode = 1;
-
- and so on. These are extremely tedious to fix by hand (there are a lot
- of them), and I am lazy, so I stole a bit of BSD Net-2 <sys/wait.h> and
- pmake compiled with only the addition of a fake utimes(2) (H.J. has told
- me that utimes() will be in the 4.2 library) and it even seems to work.
-
- Use at your own risk, but you can try adding this to <sys/wait.h>
- to make porting some old BSD software easier:
-
-
- #include <features.h>
- #ifdef __USE_BSD
-
- /*
- * Deprecated:
- * Structure of the information in the status word returned by wait4.
- * If w_stopval==WSTOPPED, then the second structure describes
- * the information returned, else the first.
- */
- union wait {
- int w_status; /* used in syscall */
- /*
- * Terminated process status.
- */
- struct {
- unsigned int w_Termsig:7, /* termination signal */
- w_Coredump:1, /* core dump indicator */
- w_Retcode:8, /* exit code if w_termsig==0 */
- w_Filler:16; /* upper bits filler */
- } w_T;
- /*
- * Stopped process status. Returned
- * only for traced children unless requested
- * with the WUNTRACED option bit.
- */
- struct {
- unsigned int w_Stopval:8, /* == W_STOPPED if stopped */
- w_Stopsig:8, /* signal that stopped us */
- w_Filler:16; /* upper bits filler */
- } w_S;
- };
- #define w_termsig w_T.w_Termsig
- #define w_coredump w_T.w_Coredump
- #define w_retcode w_T.w_Retcode
- #define w_stopval w_S.w_Stopval
- #define w_stopsig w_S.w_Stopsig
-
- #endif
-
-
-
-
- --
- Doug Quale
- quale@saavik.cs.wisc.edu
-