xref: /titanic_44/usr/src/lib/libbc/inc/include/sys/wait.h (revision ebd1706e95186ddae1d4c0d63c47544cf33832ee)
1 /*
2  * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 1982, 1986 Regents of the University of California.
8  * All rights reserved. The Berkeley software License Agreement
9  * specifies the terms and conditions for redistribution.
10  */
11 
12 #ifndef	__sys_wait_h
13 #define	__sys_wait_h
14 
15 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 /*
18  * This file holds definitions relevent to the wait system call.
19  * Some of the options here are available only through the ``wait3''
20  * entry point; the old entry point with one argument has more fixed
21  * semantics, never returning status of unstopped children, hanging until
22  * a process terminates if any are outstanding, and never returns
23  * detailed information about process resource utilization (<vtimes.h>).
24  */
25 
26 #ifndef	_POSIX_SOURCE
27 #define	__wait		wait
28 #define	w_termsig	__w_termsig
29 #define	w_coredump	__w_coredump
30 #define	w_retcode	__w_retcode
31 #define	w_stopval	__w_stopval
32 #define	w_stopsig	__w_stopsig
33 #define	WSTOPPED	_WSTOPPED
34 #endif	/* !_POSIX_SOURCE */
35 
36 /*
37  * Structure of the information in the first word returned by both
38  * wait and wait3.  If w_stopval==WSTOPPED, then the second structure
39  * describes the information returned, else the first.  See WUNTRACED below.
40  */
41 union __wait	{
42 	int	w_status;		/* used in syscall */
43 	/*
44 	 * Terminated process status.
45 	 */
46 	struct {
47 		unsigned short	w_Fill1:16;	/* high 16 bits unused */
48 		unsigned short	w_Retcode:8;	/* exit code if w_termsig==0 */
49 		unsigned short	w_Coredump:1;	/* core dump indicator */
50 		unsigned short	w_Termsig:7;	/* termination signal */
51 	} w_T;
52 	/*
53 	 * Stopped process status.  Returned
54 	 * only for traced children unless requested
55 	 * with the WUNTRACED option bit.
56 	 */
57 	struct {
58 		unsigned short	w_Fill2:16;	/* high 16 bits unused */
59 		unsigned short	w_Stopsig:8;	/* signal that stopped us */
60 		unsigned short	w_Stopval:8;	/* == W_STOPPED if stopped */
61 	} w_S;
62 };
63 #define	__w_termsig	w_T.w_Termsig
64 #define	__w_coredump	w_T.w_Coredump
65 #define	__w_retcode	w_T.w_Retcode
66 #define	__w_stopval	w_S.w_Stopval
67 #define	__w_stopsig	w_S.w_Stopsig
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)	(((union __wait*)&(x))->__w_stopval == _WSTOPPED)
83 #define	WIFSIGNALED(x)	(((union __wait*)&(x))->__w_stopval != _WSTOPPED && \
84 			((union __wait*)&(x))->__w_termsig != 0)
85 #define	WIFEXITED(x)	(((union __wait*)&(x))->__w_stopval != _WSTOPPED && \
86 			((union __wait*)&(x))->__w_termsig == 0)
87 #define	WEXITSTATUS(x)	(((union __wait*)&(x))->__w_retcode)
88 #define	WTERMSIG(x)	(((union __wait*)&(x))->__w_termsig)
89 #define	WSTOPSIG(x)	(((union __wait*)&(x))->__w_stopsig)
90 
91 #include <sys/stdtypes.h>
92 
93 pid_t	wait(/* int *loc */);
94 pid_t	waitpid(/* pid_t pid, int *loc, int opts */);
95 
96 #endif	/* !__sys_wait_h */
97