17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bdstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bdstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bdstevel@tonic-gate * with the License.
87c478bdstevel@tonic-gate *
97c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bdstevel@tonic-gate * See the License for the specific language governing permissions
127c478bdstevel@tonic-gate * and limitations under the License.
137c478bdstevel@tonic-gate *
147c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bdstevel@tonic-gate *
207c478bdstevel@tonic-gate * CDDL HEADER END
217c478bdstevel@tonic-gate */
227c478bdstevel@tonic-gate/*
237c478bdstevel@tonic-gate * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
247c478bdstevel@tonic-gate * Use is subject to license terms.
257c478bdstevel@tonic-gate */
267c478bdstevel@tonic-gate
277c478bdstevel@tonic-gate/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
287c478bdstevel@tonic-gate/*	  All Rights Reserved  	*/
297c478bdstevel@tonic-gate
307c478bdstevel@tonic-gate/*
317c478bdstevel@tonic-gate * Portions of this source code were derived from Berkeley 4.3 BSD
327c478bdstevel@tonic-gate * under license from the Regents of the University of California.
337c478bdstevel@tonic-gate */
347c478bdstevel@tonic-gate
357c478bdstevel@tonic-gate#ifndef _SYS_WAIT_H
367c478bdstevel@tonic-gate#define	_SYS_WAIT_H
377c478bdstevel@tonic-gate
387c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
397c478bdstevel@tonic-gate
407c478bdstevel@tonic-gate#include <sys/isa_defs.h>
417c478bdstevel@tonic-gate#include <sys/resource.h>
427c478bdstevel@tonic-gate
437c478bdstevel@tonic-gate#ifdef __cplusplus
447c478bdstevel@tonic-gateextern "C" {
457c478bdstevel@tonic-gate#endif
467c478bdstevel@tonic-gate
477c478bdstevel@tonic-gate/*
487c478bdstevel@tonic-gate * This wait.h is a combination of SunOS's wait.h and SysV wait.h
497c478bdstevel@tonic-gate * The structure 'union wait' is taken from SunOS, while the
507c478bdstevel@tonic-gate * rest of the #define's are from SysV.
517c478bdstevel@tonic-gate */
527c478bdstevel@tonic-gate
537c478bdstevel@tonic-gate/*
547c478bdstevel@tonic-gate * Structure of the information in the first word returned by both
557c478bdstevel@tonic-gate * wait and wait3.  If w_stopval==WSTOPPED, then the second structure
567c478bdstevel@tonic-gate * describes the information returned, else the first.  See WUNTRACED below.
577c478bdstevel@tonic-gate */
587c478bdstevel@tonic-gateunion wait	{
597c478bdstevel@tonic-gate	int	w_status;		/* used in syscall */
607c478bdstevel@tonic-gate	/*
617c478bdstevel@tonic-gate	 * Terminated process status.
627c478bdstevel@tonic-gate	 */
637c478bdstevel@tonic-gate	struct {
647c478bdstevel@tonic-gate#if defined(_BIT_FIELDS_LTOH)
657c478bdstevel@tonic-gate		unsigned short	w_Termsig:7;	/* termination signal */
667c478bdstevel@tonic-gate		unsigned short	w_Coredump:1;	/* core dump indicator */
677c478bdstevel@tonic-gate		unsigned short	w_Retcode:8;	/* exit code if w_termsig==0 */
687c478bdstevel@tonic-gate#else
697c478bdstevel@tonic-gate		unsigned short	w_Fill1:16;	/* high 16 bits unused */
707c478bdstevel@tonic-gate		unsigned short	w_Retcode:8;	/* exit code if w_termsig==0 */
717c478bdstevel@tonic-gate		unsigned short	w_Coredump:1;	/* core dump indicator */
727c478bdstevel@tonic-gate		unsigned short	w_Termsig:7;	/* termination signal */
737c478bdstevel@tonic-gate#endif
747c478bdstevel@tonic-gate	} w_T;
757c478bdstevel@tonic-gate	/*
767c478bdstevel@tonic-gate	 * Stopped process status.  Returned
777c478bdstevel@tonic-gate	 * only for traced children unless requested
787c478bdstevel@tonic-gate	 * with the WUNTRACED option bit.
797c478bdstevel@tonic-gate	 */
807c478bdstevel@tonic-gate	struct {
817c478bdstevel@tonic-gate#if defined(_BIT_FIELDS_LTOH)
827c478bdstevel@tonic-gate		unsigned short	w_Stopval:8;	/* == W_STOPPED if stopped */
837c478bdstevel@tonic-gate		unsigned short	w_Stopsig:8;	/* signal that stopped us */
847c478bdstevel@tonic-gate#else
857c478bdstevel@tonic-gate		unsigned short	w_Fill2:16;	/* high 16 bits unused */
867c478bdstevel@tonic-gate		unsigned short	w_Stopsig:8;	/* signal that stopped us */
877c478bdstevel@tonic-gate		unsigned short	w_Stopval:8;	/* == W_STOPPED if stopped */
887c478bdstevel@tonic-gate#endif
897c478bdstevel@tonic-gate	} w_S;
907c478bdstevel@tonic-gate};
917c478bdstevel@tonic-gate#define	w_termsig	w_T.w_Termsig
927c478bdstevel@tonic-gate#define	w_coredump	w_T.w_Coredump
937c478bdstevel@tonic-gate#define	w_retcode	w_T.w_Retcode
947c478bdstevel@tonic-gate#define	w_stopval	w_S.w_Stopval
957c478bdstevel@tonic-gate#define	w_stopsig	w_S.w_Stopsig
967c478bdstevel@tonic-gate
977c478bdstevel@tonic-gate/* ----- begin SysV wait.h ----- */
987c478bdstevel@tonic-gate
997c478bdstevel@tonic-gate#include <sys/types.h>
1007c478bdstevel@tonic-gate#ifdef	BUS_OBJERR	/* Namespace conflict */
1017c478bdstevel@tonic-gate#undef	BUS_OBJERR
1027c478bdstevel@tonic-gate#endif
1037c478bdstevel@tonic-gate#include <sys/siginfo.h>
1047c478bdstevel@tonic-gate#include <sys/procset.h>
1057c478bdstevel@tonic-gate
1067c478bdstevel@tonic-gate/*
1077c478bdstevel@tonic-gate * arguments to wait functions
1087c478bdstevel@tonic-gate */
1097c478bdstevel@tonic-gate
1107c478bdstevel@tonic-gate#define	WEXITED		0001	/* wait for processes that have exite	*/
1117c478bdstevel@tonic-gate#define	WTRAPPED	0002	/* wait for processes stopped while tracing */
1127c478bdstevel@tonic-gate#define	N_WSTOPPED	0004	/* wait for processes stopped by signals */
1137c478bdstevel@tonic-gate#define	WCONTINUED	0010	/* wait for processes continued */
1147c478bdstevel@tonic-gate
1157c478bdstevel@tonic-gate#define	WUNTRACED	N_WSTOPPED /* for POSIX */
1167c478bdstevel@tonic-gate
1177c478bdstevel@tonic-gate#define	WNOHANG		0100	/* non blocking form of wait	*/
1187c478bdstevel@tonic-gate#define	WNOWAIT		0200	/* non destructive form of wait */
1197c478bdstevel@tonic-gate
1207c478bdstevel@tonic-gate#define	WOPTMASK	(WEXITED|WTRAPPED|WSTOPPED|WCONTINUED|WNOHANG|WNOWAIT)
1217c478bdstevel@tonic-gate
1227c478bdstevel@tonic-gate/*
1237c478bdstevel@tonic-gate * macros for stat return from wait functions
1247c478bdstevel@tonic-gate */
1257c478bdstevel@tonic-gate
1267c478bdstevel@tonic-gate#define	WSTOPFLG		0177
1277c478bdstevel@tonic-gate#define	WSTOPPED		WSTOPFLG
1287c478bdstevel@tonic-gate				/* This is for source compatibility w/ SunOS */
1297c478bdstevel@tonic-gate#define	WCONTFLG		0177777
1307c478bdstevel@tonic-gate#define	WCOREFLG		0200
1317c478bdstevel@tonic-gate#define	WSIGMASK		0177
1327c478bdstevel@tonic-gate
1337c478bdstevel@tonic-gate#define	WLOBYTE(stat)		((int)((stat)&0377))
1347c478bdstevel@tonic-gate#define	WHIBYTE(stat)		((int)(((stat)>>8)&0377))
1357c478bdstevel@tonic-gate#define	WWORD(stat)		((int)((stat))&0177777)
1367c478bdstevel@tonic-gate
1377c478bdstevel@tonic-gate#define	WIFEXITED(stat)		(WLOBYTE(stat) == 0)
1387c478bdstevel@tonic-gate#define	WIFSIGNALED(stat)	(WLOBYTE(stat) > 0 && WHIBYTE(stat) == 0)
1397c478bdstevel@tonic-gate#define	WIFSTOPPED(stat)	(WLOBYTE(stat) == WSTOPFLG&&WHIBYTE(stat) != 0)
1407c478bdstevel@tonic-gate#define	WIFCONTINUED(stat)	(WWORD(stat) == WCONTFLG)
1417c478bdstevel@tonic-gate
1427c478bdstevel@tonic-gate#define	WEXITSTATUS(stat)	WHIBYTE(stat)
1437c478bdstevel@tonic-gate#define	WTERMSIG(stat)		(WLOBYTE(stat)&WSIGMASK)
1447c478bdstevel@tonic-gate#define	WSTOPSIG(stat)		WHIBYTE(stat)
1457c478bdstevel@tonic-gate#define	WCOREDUMP(stat)		((stat)&WCOREFLG)
1467c478bdstevel@tonic-gate
1477c478bdstevel@tonic-gate
1487c478bdstevel@tonic-gate
1497c478bdstevel@tonic-gate#if !defined(_KERNEL)
1507c478bdstevel@tonic-gate#if defined(__STDC__)
1517c478bdstevel@tonic-gate
1527c478bdstevel@tonic-gateextern pid_t wait(int *);
1537c478bdstevel@tonic-gateextern pid_t waitpid(pid_t, int *, int);
1547c478bdstevel@tonic-gateextern int waitid(idtype_t, id_t, siginfo_t *, int);
1557c478bdstevel@tonic-gateextern pid_t wait4(pid_t, int *, int, struct rusage *);
1567c478bdstevel@tonic-gateextern pid_t wait3(int *, int, struct rusage *);
1577c478bdstevel@tonic-gate
1587c478bdstevel@tonic-gate#else
1597c478bdstevel@tonic-gate
1607c478bdstevel@tonic-gateextern pid_t wait();
1617c478bdstevel@tonic-gateextern pid_t waitpid();
1627c478bdstevel@tonic-gateextern int waitid();
1637c478bdstevel@tonic-gate
1647c478bdstevel@tonic-gate#endif	/* __STDC__ */
1657c478bdstevel@tonic-gate#endif	/* _KERNEL */
1667c478bdstevel@tonic-gate
1677c478bdstevel@tonic-gate#ifdef __cplusplus
1687c478bdstevel@tonic-gate}
1697c478bdstevel@tonic-gate#endif
1707c478bdstevel@tonic-gate
1717c478bdstevel@tonic-gate#endif	/* _SYS_WAIT_H */
172