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