|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1986 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)wait.h 7.4 (Berkeley) 1/27/88 ! 7: */ ! 8: ! 9: /* ! 10: * This file holds definitions relevent to the wait system call. ! 11: * Some of the options here are available only through the ``wait3'' ! 12: * entry point; the old entry point with one argument has more fixed ! 13: * semantics, never returning status of unstopped children, hanging until ! 14: * a process terminates if any are outstanding, and never returns ! 15: * detailed information about process resource utilization (<vtimes.h>). ! 16: */ ! 17: ! 18: #ifndef BYTE_ORDER ! 19: #include <machine/endian.h> ! 20: #endif ! 21: ! 22: /* ! 23: * Structure of the information in the first word returned by both ! 24: * wait and wait3. If w_stopval==WSTOPPED, then the second structure ! 25: * describes the information returned, else the first. See WUNTRACED below. ! 26: */ ! 27: union wait { ! 28: int w_status; /* used in syscall */ ! 29: /* ! 30: * Terminated process status. ! 31: */ ! 32: struct { ! 33: #if BYTE_ORDER == LITTLE_ENDIAN ! 34: unsigned short w_Termsig:7; /* termination signal */ ! 35: unsigned short w_Coredump:1; /* core dump indicator */ ! 36: unsigned short w_Retcode:8; /* exit code if w_termsig==0 */ ! 37: #endif ! 38: #if BYTE_ORDER == BIG_ENDIAN ! 39: unsigned short w_Filler; /* upper bits filler */ ! 40: unsigned char w_Retcode; /* exit code if w_termsig==0 */ ! 41: unsigned char w_Coredump:1; /* core dump indicator */ ! 42: unsigned char w_Termsig:7; /* termination signal */ ! 43: #endif ! 44: } w_T; ! 45: /* ! 46: * Stopped process status. Returned ! 47: * only for traced children unless requested ! 48: * with the WUNTRACED option bit. ! 49: */ ! 50: struct { ! 51: #if BYTE_ORDER == LITTLE_ENDIAN ! 52: unsigned short w_Stopval:8; /* == W_STOPPED if stopped */ ! 53: unsigned short w_Stopsig:8; /* signal that stopped us */ ! 54: #else ! 55: unsigned short w_Filler; /* upper bits filler */ ! 56: unsigned char w_Stopsig; /* signal that stopped us */ ! 57: unsigned char w_Stopval; /* == W_STOPPED if stopped */ ! 58: #endif ! 59: } w_S; ! 60: }; ! 61: #define w_termsig w_T.w_Termsig ! 62: #define w_coredump w_T.w_Coredump ! 63: #define w_retcode w_T.w_Retcode ! 64: #define w_stopval w_S.w_Stopval ! 65: #define w_stopsig w_S.w_Stopsig ! 66: ! 67: ! 68: #define WSTOPPED 0177 /* value of s.stopval if process is stopped */ ! 69: ! 70: /* ! 71: * Option bits for the second argument of wait3. WNOHANG causes the ! 72: * wait to not hang if there are no stopped or terminated processes, rather ! 73: * returning an error indication in this case (pid==0). WUNTRACED ! 74: * indicates that the caller should receive status about untraced children ! 75: * which stop due to signals. If children are stopped and a wait without ! 76: * this option is done, it is as though they were still running... nothing ! 77: * about them is returned. ! 78: */ ! 79: #define WNOHANG 1 /* dont hang in wait */ ! 80: #define WUNTRACED 2 /* tell about stopped, untraced children */ ! 81: ! 82: #define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED) ! 83: #define WIFSIGNALED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig != 0) ! 84: #define WIFEXITED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig == 0)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.