/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

#ident		"$Header: wait.h 1.7 90/07/29 $"

#ifndef	_SYS_WAIT_H_

/*
 * wait.h
 *	This file holds definitions relevent to the wait system call.
 *
 * The options here are available only through the ``waitpid''
 * entry point; the old entry point with one argument has more fixed
 * semantics, never returning status of unstopped children, and
 * hanging until a process terminates if any are outstanding.
 */

/* $Log:	wait.h,v $
 */


/*____________________________________________________________________*
 * This file forms part of the POSIX requirement described in section *
 * 3.2 of 1003.1-1988 which should be refered to before making any    *
 * changes.							      *
 *____________________________________________________________________*/

/* POSIX 1003.1-1988 3.2.1.2 */

/*
 * Evaluates to a non-zero value if status was returned for a child
 * process that terminated normally.
 */
#define	WIFEXITED(s)	(((int)(s) & 0xFF) ? 0 : 1)

/*
 * Evaluates to a non-zero value if status was returned for a child
 * process that terminated due to the receipt of a signal that was 
 * not caught. 
 */
#define	WIFSIGNALED(s)	((((int)(s) & 0x7F) && \
			(WIFSTOPPED(s) == 0)) ? 1 : 0)

/*
 * Evaluates to a non-zero value if status was returned for a child
 * process that is currently stopped.
 */
#define	WIFSTOPPED(s)	((((int)(s) & 0x7F) == 0x7F) ? 1 : 0)

/*
 * Evaluates to the low-order 8 bits of the status argument that the
 * child process passed to _exit() or exit(), or the value the child
 * process returned from main().
 */
#define WEXITSTATUS(s)	(((int)(s) & 0xFF00) >> 8)

/*
 * If WIFSIGNALED() is non-zero, this returns the signal number that
 * caused the child process to terminate.
 */
#define	WTERMSIG(s)	(WIFSIGNALED(s) ? ((int)(s) & 0x7F) : 0)

/* 
 * If WIFSTOPPED() is non-zero, this returns the signal number that
 * caused the child process to stop.
 */
#define	WSTOPSIG(s)	(WIFSTOPPED(s) ? (((int)(s) & 0xFF00) >> 8) : 0)

#ifndef	_POSIX_SOURCE

#define	WSTOPPED	0177
#define WIFCORESIG(s)	(s & 0x80)

#endif	/*_POSIX_SOURCE*/

/*
 * Option bits for the second argument of waitpid.  WNOHANG causes the
 * wait to not hang if there are no stopped or terminated processes, rather
 * returning an error indication in this case (pid==0).  WUNTRACED
 * indicates that the caller should receive status about untraced children
 * which stop due to signals.  If children are stopped and a wait without
 * this option is done, it is as though they were still running... nothing
 * about them is returned.
 */
#define WNOHANG		0x1	/* dont hang in wait */
#define WUNTRACED	0x2	/* tell about stopped, untraced children */


#ifndef INKERNEL
extern pid_t wait();
extern pid_t waitpid();
#endif /* INKERNEL */

#define	_SYS_WAIT_H_
#endif	/*_SYS_WAIT_H_*/

