159243Sobrien/* The <sys/wait.h> header contains macros related to wait(). The value
259243Sobrien * returned by wait() and waitpid() depends on whether the process
359243Sobrien * terminated by an exit() call, was killed by a signal, or was stopped
459243Sobrien * due to job control, as follows:
559243Sobrien *
659243Sobrien *				 High byte   Low byte
759243Sobrien *				+---------------------+
859243Sobrien *	exit(status)		|  status  |    0     |
959243Sobrien *				+---------------------+
1059243Sobrien *      killed by signal	|    0     |  signal  |
1159243Sobrien *				+---------------------+
1259243Sobrien *	stopped (job control)	|  signal  |   0177   |
1359243Sobrien *				+---------------------+
1459243Sobrien */
1559243Sobrien
1659243Sobrien#ifndef _WAIT_H
1759243Sobrien#define _WAIT_H
1859243Sobrien
1959243Sobrien#ifndef _TYPES_H		/* not quite right */
2059243Sobrien#include <sys/types.h>
2159243Sobrien#endif
2259243Sobrien
2359243Sobrien#define __LOW(v)	((v) & 0377)
2459243Sobrien#define __HIGH(v)	(((v) >> 8) & 0377)
2559243Sobrien
2659243Sobrien#define WNOHANG         1	/* do not wait for child to exit */
2759243Sobrien#define WUNTRACED       2	/* for job control; not implemented */
2859243Sobrien
2959243Sobrien#define WIFEXITED(s)	(__LOW(s) == 0)		    /* normal exit */
3059243Sobrien#define WEXITSTATUS(s)	(__HIGH(s))			    /* exit status */
3159243Sobrien#define WTERMSIG(s)	(__LOW(s) & 0177)		    /* sig value */
3259243Sobrien#define WIFSIGNALED(s)	((((unsigned int)(s)-1) & 0xFFFF) < 0xFF) /* signaled */
3359243Sobrien#define WIFSTOPPED(s)	(__LOW(s) == 0177)		    /* stopped */
3459243Sobrien#define WSTOPSIG(s)	(__HIGH(s) & 0377)		    /* stop signal */
3559243Sobrien
3659243Sobrien/* Function Prototypes. */
3759243Sobrien#ifndef _ANSI_H
3859243Sobrien#include <ansi.h>
3959243Sobrien#endif
4059243Sobrien
4159243Sobrien_PROTOTYPE( pid_t wait, (int *_stat_loc)			   	   );
4259243Sobrien_PROTOTYPE( pid_t waitpid, (pid_t _pid, int *_stat_loc, int _options)	   );
4359243Sobrien
4459243Sobrien#endif /* _WAIT_H */
45