/*	@(#)wait.h 2.18 89/06/25 SMI; from UCB 4.1 83/02/10	*/

/*
 * This file holds definitions relevent to the wait system call.
 * Some of the options here are available only through the ``wait3''
 * entry point; the old entry point with one argument has more fixed
 * semantics, never returning status of unstopped children, hanging until
 * a process terminates if any are outstanding, and never returns
 * detailed information about process resource utilization (<vtimes.h>).
 */

#ifndef	__sys_wait_h
#define	__sys_wait_h

#include <sys/types.h>
#include <sys/resource.h>

/* Bits in the third argument to `waitpid'.  */
#define	WNOHANG		1	/* Don't block waiting.  */
#define	WUNTRACED	2	/* Report status of stopped children.  */

#define __WALL		0x40000000 /* Wait for any child.  */
#define __WCLONE	0x80000000 /* Wait for cloned process.  */

/* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */
#define	WEXITSTATUS(status)   (((status) & 0xff00) >> 8)

/* If WIFSIGNALED(STATUS), the terminating signal.  */
#define	WTERMSIG(status)      ((status) & 0x7f)

/* If WIFSTOPPED(STATUS), the signal that stopped the child.  */
#define	WSTOPSIG(status)      WEXITSTATUS(status)

/* Nonzero if STATUS indicates normal termination.  */
#define	WIFEXITED(status)     (WTERMSIG(status) == 0)

/* Nonzero if STATUS indicates termination by a signal.  */
#define WIFSIGNALED(status)   (!WIFSTOPPED(status) && !WIFEXITED(status))

/* Nonzero if STATUS indicates the child is stopped.  */
#define	WIFSTOPPED(status)    (((status) & 0xff) == 0x7f)

/* Nonzero if STATUS indicates the child dumped core.  */
#define	WCOREDUMP(status)     ((status) & 0x80)


pid_t	wait(int *status);

pid_t	waitpid(pid_t pid, int* status, int options);

pid_t	wait4(pid_t pid, int* status, int options, struct rusage *rusage);

#endif	/* !__sys_wait_h */

