home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / linux / 17509 < prev    next >
Encoding:
Text File  |  1992-11-21  |  2.9 KB  |  92 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!cs.utexas.edu!uwm.edu!daffy!spock.cs.wisc.edu!quale
  3. From: quale@spock.cs.wisc.edu (Doug Quale)
  4. Subject: Re: union wait
  5. Message-ID: <1992Nov22.035031.24640@daffy.cs.wisc.edu>
  6. Sender: news@daffy.cs.wisc.edu (The News)
  7. Organization: Undergraduate Projects Lab, UW-Madison
  8. References: <Mf35FIC00YUnR=rW82@andrew.cmu.edu> <1992Nov20.193111.995@serval.net.wsu.edu> <kenc.722383317@sol>
  9. Date: Sun, 22 Nov 1992 03:50:31 GMT
  10. Lines: 80
  11.  
  12. In article <kenc.722383317@sol> kenc@sol.acs.unt.edu (Ken Corey - Operator) writes:
  13. >hlu@eecs.wsu.edu (H.J. Lu) writes:
  14. >
  15. >>Include <sys/wait.h>, You are home free. If your software ueses "union wait"
  16. >>directly, rather than wait macros, fix your software. That will make it
  17. >>more portable.
  18. >
  19. >
  20. >Don't forget, <wait.h> defines the union wait structure as an 'int *'.  
  21. >Simply search and replace using your favorite editor, and things should work 
  22. >out just fine.  At least *i*'ve gotten good results...your mileage may vary.
  23. >
  24.  
  25. I probably *really* shouldn't post this, since this hasn't been well
  26. tested or even thought out, but
  27.  
  28. John T. Kohl (I hope I remembered his name correctly, apologies if I
  29. goofed, he is now active in 386BSD) did a port of BSD make (pmake) to
  30. Linux in the early days.  It was binary only (he would provide source
  31. to those who asked, but I was too lazy).  BSD make makes the most
  32. egregious use of union wait I can imagine -- it uses the structure
  33. elements as lvalues (it assigns to them).  The code is full of
  34. statements such as
  35.  
  36. status.w_retcode = 1;
  37.  
  38. and so on.  These are extremely tedious to fix by hand (there are a lot
  39. of them), and I am lazy, so I stole a bit of BSD Net-2 <sys/wait.h> and
  40. pmake compiled with only the addition of a fake utimes(2) (H.J. has told
  41. me that utimes() will be in the 4.2 library) and it even seems to work.
  42.  
  43. Use at your own risk, but you can try adding this to <sys/wait.h>
  44. to make porting some old BSD software easier:
  45.  
  46.  
  47. #include <features.h>
  48. #ifdef __USE_BSD
  49.  
  50. /*
  51.  * Deprecated:
  52.  * Structure of the information in the status word returned by wait4.
  53.  * If w_stopval==WSTOPPED, then the second structure describes
  54.  * the information returned, else the first.
  55.  */
  56. union wait {
  57.     int    w_status;        /* used in syscall */
  58.     /*
  59.      * Terminated process status.
  60.      */
  61.     struct {
  62.         unsigned int    w_Termsig:7,    /* termination signal */
  63.                 w_Coredump:1,    /* core dump indicator */
  64.                 w_Retcode:8,    /* exit code if w_termsig==0 */
  65.                 w_Filler:16;    /* upper bits filler */
  66.     } w_T;
  67.     /*
  68.      * Stopped process status.  Returned
  69.      * only for traced children unless requested
  70.      * with the WUNTRACED option bit.
  71.      */
  72.     struct {
  73.         unsigned int    w_Stopval:8,    /* == W_STOPPED if stopped */
  74.                 w_Stopsig:8,    /* signal that stopped us */
  75.                 w_Filler:16;    /* upper bits filler */
  76.     } w_S;
  77. };
  78. #define    w_termsig    w_T.w_Termsig
  79. #define w_coredump    w_T.w_Coredump
  80. #define w_retcode    w_T.w_Retcode
  81. #define w_stopval    w_S.w_Stopval
  82. #define w_stopsig    w_S.w_Stopsig
  83.  
  84. #endif
  85.  
  86.  
  87.  
  88.  
  89. -- 
  90. Doug Quale
  91. quale@saavik.cs.wisc.edu
  92.