1 0 stevel /* 2 200 raf * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3 0 stevel * Use is subject to license terms. 4 200 raf */ 5 200 raf 6 200 raf /* 7 0 stevel * 8 0 stevel * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T 9 0 stevel * All Rights Reserved 10 0 stevel * 11 0 stevel * Copyright (c) 1980 Regents of the University of California. 12 0 stevel * All rights reserved. The Berkeley Software License Agreement 13 0 stevel * specifies the terms and conditions for redistribution. 14 0 stevel */ 15 0 stevel 16 0 stevel #pragma ident "%Z%%M% %I% %E% SMI" 17 0 stevel 18 0 stevel /* 19 3517 mp204432 * This file holds definitions relevant to the wait system call. 20 0 stevel * Some of the options here are available only through the ``wait3'' 21 0 stevel * entry point; the old entry point with one argument has more fixed 22 0 stevel * semantics, never returning status of unstopped children, hanging until 23 0 stevel * a process terminates if any are outstanding, and never returns 24 0 stevel * detailed information about process resource utilization (<vtimes.h>). 25 0 stevel */ 26 0 stevel 27 0 stevel #ifndef _sys_wait_h 28 200 raf #define _sys_wait_h 29 0 stevel 30 200 raf #include <sys/isa_defs.h> /* included for _LITTLE_ENDIAN define */ 31 0 stevel 32 0 stevel /* 33 0 stevel * Structure of the information in the first word returned by both 34 0 stevel * wait and wait3. If w_stopval==WSTOPPED, then the second structure 35 0 stevel * describes the information returned, else the first. See WUNTRACED below. 36 0 stevel */ 37 0 stevel union wait { 38 0 stevel int w_status; /* used in syscall */ 39 0 stevel /* 40 0 stevel * Terminated process status. 41 0 stevel */ 42 0 stevel struct { 43 0 stevel #if defined(_LITTLE_ENDIAN) 44 0 stevel unsigned short w_Termsig:7; /* termination signal */ 45 0 stevel unsigned short w_Coredump:1; /* core dump indicator */ 46 0 stevel unsigned short w_Retcode:8; /* exit code if w_termsig==0 */ 47 0 stevel #elif defined(_BIG_ENDIAN) 48 0 stevel unsigned short w_Fill1:16; /* high 16 bits unused */ 49 0 stevel unsigned short w_Retcode:8; /* exit code if w_termsig==0 */ 50 0 stevel unsigned short w_Coredump:1; /* core dump indicator */ 51 0 stevel unsigned short w_Termsig:7; /* termination signal */ 52 0 stevel #else 53 0 stevel #error NO ENDIAN defined. 54 0 stevel #endif 55 0 stevel } w_T; 56 0 stevel /* 57 0 stevel * Stopped process status. Returned 58 0 stevel * only for traced children unless requested 59 0 stevel * with the WUNTRACED option bit. 60 0 stevel */ 61 0 stevel struct { 62 0 stevel #if defined(_LITTLE_ENDIAN) 63 0 stevel unsigned short w_Stopval:8; /* == W_STOPPED if stopped */ 64 0 stevel unsigned short w_Stopsig:8; /* signal that stopped us */ 65 0 stevel #elif defined(_BIG_ENDIAN) 66 0 stevel unsigned short w_Fill2:16; /* high 16 bits unused */ 67 0 stevel unsigned short w_Stopsig:8; /* signal that stopped us */ 68 0 stevel unsigned short w_Stopval:8; /* == W_STOPPED if stopped */ 69 0 stevel #else 70 0 stevel #error NO ENDIAN defined. 71 0 stevel #endif 72 0 stevel } w_S; 73 0 stevel }; 74 0 stevel #define w_termsig w_T.w_Termsig 75 200 raf #define w_coredump w_T.w_Coredump 76 200 raf #define w_retcode w_T.w_Retcode 77 200 raf #define w_stopval w_S.w_Stopval 78 200 raf #define w_stopsig w_S.w_Stopsig 79 0 stevel 80 0 stevel 81 0 stevel #define WSTOPPED 0177 /* value of s.stopval if process is stopped */ 82 200 raf #define WCONTFLG 0177777 /* value of w.w_status due to SIGCONT, sysV */ 83 0 stevel 84 0 stevel /* 85 0 stevel * Option bits for the second argument of wait3. WNOHANG causes the 86 0 stevel * wait to not hang if there are no stopped or terminated processes, rather 87 0 stevel * returning an error indication in this case (pid==0). WUNTRACED 88 0 stevel * indicates that the caller should receive status about untraced children 89 0 stevel * which stop due to signals. If children are stopped and a wait without 90 0 stevel * this option is done, it is as though they were still running... nothing 91 0 stevel * about them is returned. 92 0 stevel */ 93 200 raf #define WNOHANG 1 /* dont hang in wait */ 94 200 raf #define WUNTRACED 2 /* tell about stopped, untraced children */ 95 0 stevel 96 200 raf #define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED) 97 200 raf #define WIFSIGNALED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig != 0) 98 200 raf #define WIFEXITED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig == 0) 99 0 stevel 100 200 raf extern pid_t csh_wait3(union wait *w, int options, struct rusage *rp); 101 200 raf extern pid_t csh_wait_noreap(void); 102 0 stevel 103 200 raf #endif /* _sys_wait_h */ 104