10Sstevel@tonic-gate /* 2200Sraf * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 30Sstevel@tonic-gate * Use is subject to license terms. 4200Sraf */ 5200Sraf 6200Sraf /* 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T 90Sstevel@tonic-gate * All Rights Reserved 100Sstevel@tonic-gate * 110Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 120Sstevel@tonic-gate * All rights reserved. The Berkeley Software License Agreement 130Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 140Sstevel@tonic-gate */ 150Sstevel@tonic-gate 160Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 170Sstevel@tonic-gate 180Sstevel@tonic-gate /* 19*3517Smp204432 * This file holds definitions relevant to the wait system call. 200Sstevel@tonic-gate * Some of the options here are available only through the ``wait3'' 210Sstevel@tonic-gate * entry point; the old entry point with one argument has more fixed 220Sstevel@tonic-gate * semantics, never returning status of unstopped children, hanging until 230Sstevel@tonic-gate * a process terminates if any are outstanding, and never returns 240Sstevel@tonic-gate * detailed information about process resource utilization (<vtimes.h>). 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _sys_wait_h 28200Sraf #define _sys_wait_h 290Sstevel@tonic-gate 30200Sraf #include <sys/isa_defs.h> /* included for _LITTLE_ENDIAN define */ 310Sstevel@tonic-gate 320Sstevel@tonic-gate /* 330Sstevel@tonic-gate * Structure of the information in the first word returned by both 340Sstevel@tonic-gate * wait and wait3. If w_stopval==WSTOPPED, then the second structure 350Sstevel@tonic-gate * describes the information returned, else the first. See WUNTRACED below. 360Sstevel@tonic-gate */ 370Sstevel@tonic-gate union wait { 380Sstevel@tonic-gate int w_status; /* used in syscall */ 390Sstevel@tonic-gate /* 400Sstevel@tonic-gate * Terminated process status. 410Sstevel@tonic-gate */ 420Sstevel@tonic-gate struct { 430Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 440Sstevel@tonic-gate unsigned short w_Termsig:7; /* termination signal */ 450Sstevel@tonic-gate unsigned short w_Coredump:1; /* core dump indicator */ 460Sstevel@tonic-gate unsigned short w_Retcode:8; /* exit code if w_termsig==0 */ 470Sstevel@tonic-gate #elif defined(_BIG_ENDIAN) 480Sstevel@tonic-gate unsigned short w_Fill1:16; /* high 16 bits unused */ 490Sstevel@tonic-gate unsigned short w_Retcode:8; /* exit code if w_termsig==0 */ 500Sstevel@tonic-gate unsigned short w_Coredump:1; /* core dump indicator */ 510Sstevel@tonic-gate unsigned short w_Termsig:7; /* termination signal */ 520Sstevel@tonic-gate #else 530Sstevel@tonic-gate #error NO ENDIAN defined. 540Sstevel@tonic-gate #endif 550Sstevel@tonic-gate } w_T; 560Sstevel@tonic-gate /* 570Sstevel@tonic-gate * Stopped process status. Returned 580Sstevel@tonic-gate * only for traced children unless requested 590Sstevel@tonic-gate * with the WUNTRACED option bit. 600Sstevel@tonic-gate */ 610Sstevel@tonic-gate struct { 620Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 630Sstevel@tonic-gate unsigned short w_Stopval:8; /* == W_STOPPED if stopped */ 640Sstevel@tonic-gate unsigned short w_Stopsig:8; /* signal that stopped us */ 650Sstevel@tonic-gate #elif defined(_BIG_ENDIAN) 660Sstevel@tonic-gate unsigned short w_Fill2:16; /* high 16 bits unused */ 670Sstevel@tonic-gate unsigned short w_Stopsig:8; /* signal that stopped us */ 680Sstevel@tonic-gate unsigned short w_Stopval:8; /* == W_STOPPED if stopped */ 690Sstevel@tonic-gate #else 700Sstevel@tonic-gate #error NO ENDIAN defined. 710Sstevel@tonic-gate #endif 720Sstevel@tonic-gate } w_S; 730Sstevel@tonic-gate }; 740Sstevel@tonic-gate #define w_termsig w_T.w_Termsig 75200Sraf #define w_coredump w_T.w_Coredump 76200Sraf #define w_retcode w_T.w_Retcode 77200Sraf #define w_stopval w_S.w_Stopval 78200Sraf #define w_stopsig w_S.w_Stopsig 790Sstevel@tonic-gate 800Sstevel@tonic-gate 810Sstevel@tonic-gate #define WSTOPPED 0177 /* value of s.stopval if process is stopped */ 82200Sraf #define WCONTFLG 0177777 /* value of w.w_status due to SIGCONT, sysV */ 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * Option bits for the second argument of wait3. WNOHANG causes the 860Sstevel@tonic-gate * wait to not hang if there are no stopped or terminated processes, rather 870Sstevel@tonic-gate * returning an error indication in this case (pid==0). WUNTRACED 880Sstevel@tonic-gate * indicates that the caller should receive status about untraced children 890Sstevel@tonic-gate * which stop due to signals. If children are stopped and a wait without 900Sstevel@tonic-gate * this option is done, it is as though they were still running... nothing 910Sstevel@tonic-gate * about them is returned. 920Sstevel@tonic-gate */ 93200Sraf #define WNOHANG 1 /* dont hang in wait */ 94200Sraf #define WUNTRACED 2 /* tell about stopped, untraced children */ 950Sstevel@tonic-gate 96200Sraf #define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED) 97200Sraf #define WIFSIGNALED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig != 0) 98200Sraf #define WIFEXITED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig == 0) 990Sstevel@tonic-gate 100200Sraf extern pid_t csh_wait3(union wait *w, int options, struct rusage *rp); 101200Sraf extern pid_t csh_wait_noreap(void); 102200Sraf 103200Sraf #endif /* _sys_wait_h */ 104