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