home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 25.ddi / root.2 / usr / ucbinclude / sys / wait.h < prev   
Encoding:
C/C++ Source or Header  |  1990-12-08  |  4.3 KB  |  152 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10.  
  11. #ident    "@(#)//usr/ucbinclude/sys/wait.h.sl 1.1 4.0 12/08/90 61246 AT&T-USL"
  12.  
  13. /*******************************************************************
  14.  
  15.         PROPRIETARY NOTICE (Combined)
  16.  
  17. This source code is unpublished proprietary information
  18. constituting, or derived under license from AT&T's UNIX(r) System V.
  19. In addition, portions of such source code were derived from Berkeley
  20. 4.3 BSD under license from the Regents of the University of
  21. California.
  22.  
  23.  
  24.  
  25.         Copyright Notice 
  26.  
  27. Notice of copyright on this source code product does not indicate 
  28. publication.
  29.  
  30.     (c) 1986,1987,1988,1989  Sun Microsystems, Inc
  31.     (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
  32.               All rights reserved.
  33. ********************************************************************/ 
  34.  
  35. /*
  36.  * This wait.h is a combination of SunOS's wait.h and SysV wait.h
  37.  * The structure 'union wait' is taken from SunOS, while the
  38.  * rest of the #define's are from SysV.
  39.  */
  40.  
  41. /*
  42.  * Structure of the information in the first word returned by both
  43.  * wait and wait3.  If w_stopval==WSTOPPED, then the second structure
  44.  * describes the information returned, else the first.  See WUNTRACED below.
  45.  */
  46. union wait    {
  47.     int    w_status;        /* used in syscall */
  48.     /*
  49.      * Terminated process status.
  50.      */
  51.     struct {
  52. #if defined(vax) || defined(i386)
  53.         unsigned short    w_Termsig:7;    /* termination signal */
  54.         unsigned short    w_Coredump:1;    /* core dump indicator */
  55.         unsigned short    w_Retcode:8;    /* exit code if w_termsig==0 */
  56. #else
  57.         unsigned short    w_Fill1:16;    /* high 16 bits unused */
  58.         unsigned short    w_Retcode:8;    /* exit code if w_termsig==0 */
  59.         unsigned short    w_Coredump:1;    /* core dump indicator */
  60.         unsigned short    w_Termsig:7;    /* termination signal */
  61. #endif
  62.     } w_T;
  63.     /*
  64.      * Stopped process status.  Returned
  65.      * only for traced children unless requested
  66.      * with the WUNTRACED option bit.
  67.      */
  68.     struct {
  69. #if defined(vax) || defined(i386)
  70.         unsigned short    w_Stopval:8;    /* == W_STOPPED if stopped */
  71.         unsigned short    w_Stopsig:8;    /* signal that stopped us */
  72. #else
  73.         unsigned short    w_Fill2:16;    /* high 16 bits unused */
  74.         unsigned short    w_Stopsig:8;    /* signal that stopped us */
  75.         unsigned short    w_Stopval:8;    /* == W_STOPPED if stopped */
  76. #endif
  77.     } w_S;
  78. };
  79. #define    w_termsig    w_T.w_Termsig
  80. #define w_coredump    w_T.w_Coredump
  81. #define w_retcode    w_T.w_Retcode
  82. #define w_stopval    w_S.w_Stopval
  83. #define w_stopsig    w_S.w_Stopsig
  84.  
  85. /* ----- begin SysV wait.h ----- */
  86.  
  87. #ifndef _SYS_WAIT_H
  88. #define _SYS_WAIT_H
  89.  
  90. #include "sys/types.h"
  91. #include "sys/siginfo.h"
  92. #include "sys/procset.h"
  93.  
  94. /*
  95.  * arguments to wait functions
  96.  */
  97.  
  98. #define WEXITED        0001    /* wait for processes that have exite    */
  99. #define WTRAPPED    0002    /* wait for processes stopped while tracing */
  100. #define WSTOPPED    0004    /* wait for processes stopped by signals */
  101. #define WCONTINUED    0010    /* wait for processes continued */
  102.  
  103. #define WUNTRACED    WSTOPPED /* for POSIX */
  104.  
  105. #define WNOHANG        0100    /* non blocking form of wait    */
  106. #define WNOWAIT        0200    /* non destructive form of wait */
  107.  
  108. #define WOPTMASK    (WEXITED|WTRAPPED|WSTOPPED|WCONTINUED|WNOHANG|WNOWAIT)
  109.  
  110. /*
  111.  * macros for stat return from wait functions
  112.  */
  113.  
  114. #define WSTOPFLG        0177
  115. #define WCONTFLG        0177777
  116. #define WCOREFLG        0200
  117. #define WSIGMASK        0177
  118.  
  119. #define WLOBYTE(stat)        ((int)((stat)&0377))
  120. #define WHIBYTE(stat)        ((int)(((stat)>>8)&0377))
  121. #define WWORD(stat)        ((int)((stat))&0177777)
  122.  
  123. #define WIFEXITED(stat)        (WLOBYTE(stat)==0)
  124. #define WIFSIGNALED(stat)    (WLOBYTE(stat)>0&&WHIBYTE(stat)==0)
  125. #define WIFSTOPPED(stat)    (WLOBYTE(stat)==WSTOPFLG&&WHIBYTE(stat)!=0)
  126. #define WIFCONTINUED(stat)    (WWORD(stat)==WCONTFLG)
  127.  
  128. #define WEXITSTATUS(stat)    WHIBYTE(stat)
  129. #define WTERMSIG(stat)        (WLOBYTE(stat)&WSIGMASK)
  130. #define WSTOPSIG(stat)        WHIBYTE(stat)
  131. #define WCOREDUMP(stat)        ((stat)&WCOREFLG)
  132.  
  133.  
  134.  
  135. #if !defined(_KERNEL)
  136. #if defined(__STDC__)
  137.  
  138. extern pid_t wait(int *);
  139. extern pid_t waitpid(pid_t, int *, int);
  140. extern int waitid(idtype_t, id_t, siginfo_t *, int);
  141.  
  142. #else
  143.  
  144. extern pid_t wait();
  145. extern pid_t waitpid();
  146. extern int waitid();
  147.  
  148. #endif    /* __STDC__ */
  149. #endif    /* _KERNEL */
  150.  
  151. #endif    /* _SYS_WAIT_H */
  152.