17c478bd9Sstevel@tonic-gate /* 28e3c57a3Sraf * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 48e3c57a3Sraf */ 58e3c57a3Sraf 68e3c57a3Sraf /* 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T 97c478bd9Sstevel@tonic-gate * All Rights Reserved 107c478bd9Sstevel@tonic-gate * 117c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 127c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley Software License Agreement 137c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 147c478bd9Sstevel@tonic-gate */ 157c478bd9Sstevel@tonic-gate 167c478bd9Sstevel@tonic-gate /* 17*63360950Smp * This file holds definitions relevant to the wait system call. 187c478bd9Sstevel@tonic-gate * Some of the options here are available only through the ``wait3'' 197c478bd9Sstevel@tonic-gate * entry point; the old entry point with one argument has more fixed 207c478bd9Sstevel@tonic-gate * semantics, never returning status of unstopped children, hanging until 217c478bd9Sstevel@tonic-gate * a process terminates if any are outstanding, and never returns 227c478bd9Sstevel@tonic-gate * detailed information about process resource utilization (<vtimes.h>). 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _sys_wait_h 268e3c57a3Sraf #define _sys_wait_h 277c478bd9Sstevel@tonic-gate 288e3c57a3Sraf #include <sys/isa_defs.h> /* included for _LITTLE_ENDIAN define */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * Structure of the information in the first word returned by both 327c478bd9Sstevel@tonic-gate * wait and wait3. If w_stopval==WSTOPPED, then the second structure 337c478bd9Sstevel@tonic-gate * describes the information returned, else the first. See WUNTRACED below. 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate union wait { 367c478bd9Sstevel@tonic-gate int w_status; /* used in syscall */ 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * Terminated process status. 397c478bd9Sstevel@tonic-gate */ 407c478bd9Sstevel@tonic-gate struct { 417c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 427c478bd9Sstevel@tonic-gate unsigned short w_Termsig:7; /* termination signal */ 437c478bd9Sstevel@tonic-gate unsigned short w_Coredump:1; /* core dump indicator */ 447c478bd9Sstevel@tonic-gate unsigned short w_Retcode:8; /* exit code if w_termsig==0 */ 457c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN) 467c478bd9Sstevel@tonic-gate unsigned short w_Fill1:16; /* high 16 bits unused */ 477c478bd9Sstevel@tonic-gate unsigned short w_Retcode:8; /* exit code if w_termsig==0 */ 487c478bd9Sstevel@tonic-gate unsigned short w_Coredump:1; /* core dump indicator */ 497c478bd9Sstevel@tonic-gate unsigned short w_Termsig:7; /* termination signal */ 507c478bd9Sstevel@tonic-gate #else 517c478bd9Sstevel@tonic-gate #error NO ENDIAN defined. 527c478bd9Sstevel@tonic-gate #endif 537c478bd9Sstevel@tonic-gate } w_T; 547c478bd9Sstevel@tonic-gate /* 557c478bd9Sstevel@tonic-gate * Stopped process status. Returned 567c478bd9Sstevel@tonic-gate * only for traced children unless requested 577c478bd9Sstevel@tonic-gate * with the WUNTRACED option bit. 587c478bd9Sstevel@tonic-gate */ 597c478bd9Sstevel@tonic-gate struct { 607c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 617c478bd9Sstevel@tonic-gate unsigned short w_Stopval:8; /* == W_STOPPED if stopped */ 627c478bd9Sstevel@tonic-gate unsigned short w_Stopsig:8; /* signal that stopped us */ 637c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN) 647c478bd9Sstevel@tonic-gate unsigned short w_Fill2:16; /* high 16 bits unused */ 657c478bd9Sstevel@tonic-gate unsigned short w_Stopsig:8; /* signal that stopped us */ 667c478bd9Sstevel@tonic-gate unsigned short w_Stopval:8; /* == W_STOPPED if stopped */ 677c478bd9Sstevel@tonic-gate #else 687c478bd9Sstevel@tonic-gate #error NO ENDIAN defined. 697c478bd9Sstevel@tonic-gate #endif 707c478bd9Sstevel@tonic-gate } w_S; 717c478bd9Sstevel@tonic-gate }; 727c478bd9Sstevel@tonic-gate #define w_termsig w_T.w_Termsig 738e3c57a3Sraf #define w_coredump w_T.w_Coredump 748e3c57a3Sraf #define w_retcode w_T.w_Retcode 758e3c57a3Sraf #define w_stopval w_S.w_Stopval 768e3c57a3Sraf #define w_stopsig w_S.w_Stopsig 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate #define WSTOPPED 0177 /* value of s.stopval if process is stopped */ 808e3c57a3Sraf #define WCONTFLG 0177777 /* value of w.w_status due to SIGCONT, sysV */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* 837c478bd9Sstevel@tonic-gate * Option bits for the second argument of wait3. WNOHANG causes the 847c478bd9Sstevel@tonic-gate * wait to not hang if there are no stopped or terminated processes, rather 857c478bd9Sstevel@tonic-gate * returning an error indication in this case (pid==0). WUNTRACED 867c478bd9Sstevel@tonic-gate * indicates that the caller should receive status about untraced children 877c478bd9Sstevel@tonic-gate * which stop due to signals. If children are stopped and a wait without 887c478bd9Sstevel@tonic-gate * this option is done, it is as though they were still running... nothing 897c478bd9Sstevel@tonic-gate * about them is returned. 907c478bd9Sstevel@tonic-gate */ 918e3c57a3Sraf #define WNOHANG 1 /* dont hang in wait */ 928e3c57a3Sraf #define WUNTRACED 2 /* tell about stopped, untraced children */ 937c478bd9Sstevel@tonic-gate 948e3c57a3Sraf #define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED) 958e3c57a3Sraf #define WIFSIGNALED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig != 0) 968e3c57a3Sraf #define WIFEXITED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig == 0) 977c478bd9Sstevel@tonic-gate 988e3c57a3Sraf extern pid_t csh_wait3(union wait *w, int options, struct rusage *rp); 998e3c57a3Sraf extern pid_t csh_wait_noreap(void); 1007c478bd9Sstevel@tonic-gate 1018e3c57a3Sraf #endif /* _sys_wait_h */ 102