wait.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
1280N/A/*
1280N/A * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
1280N/A * Use is subject to license terms.
1280N/A *
1280N/A * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T
1280N/A * All Rights Reserved
1280N/A *
1280N/A * Copyright (c) 1980 Regents of the University of California.
1280N/A * All rights reserved. The Berkeley Software License Agreement
1280N/A * specifies the terms and conditions for redistribution.
1280N/A */
1280N/A
1280N/A#pragma ident "%Z%%M% %I% %E% SMI"
1280N/A
1280N/A/*
1280N/A * This file holds definitions relevent to the wait system call.
1280N/A * Some of the options here are available only through the ``wait3''
1280N/A * entry point; the old entry point with one argument has more fixed
1280N/A * semantics, never returning status of unstopped children, hanging until
1280N/A * a process terminates if any are outstanding, and never returns
1280N/A * detailed information about process resource utilization (<vtimes.h>).
1280N/A */
1280N/A
1280N/A#ifndef _sys_wait_h
1280N/A#define _sys_wait_h
1280N/A
1280N/A#include <sys/isa_defs.h> /* included for _LITTLE_ENDIAN define */
1280N/A
1280N/A/*
1280N/A * Structure of the information in the first word returned by both
1280N/A * wait and wait3. If w_stopval==WSTOPPED, then the second structure
1280N/A * describes the information returned, else the first. See WUNTRACED below.
1280N/A */
1280N/Aunion wait {
1280N/A int w_status; /* used in syscall */
1280N/A /*
1280N/A * Terminated process status.
1280N/A */
1280N/A struct {
1280N/A#if defined(_LITTLE_ENDIAN)
1280N/A unsigned short w_Termsig:7; /* termination signal */
1280N/A unsigned short w_Coredump:1; /* core dump indicator */
1280N/A unsigned short w_Retcode:8; /* exit code if w_termsig==0 */
1280N/A#elif defined(_BIG_ENDIAN)
1280N/A unsigned short w_Fill1:16; /* high 16 bits unused */
1280N/A unsigned short w_Retcode:8; /* exit code if w_termsig==0 */
1280N/A unsigned short w_Coredump:1; /* core dump indicator */
1280N/A unsigned short w_Termsig:7; /* termination signal */
1280N/A#else
1280N/A#error NO ENDIAN defined.
1280N/A#endif
1280N/A } w_T;
1280N/A /*
1280N/A * Stopped process status. Returned
1280N/A * only for traced children unless requested
1280N/A * with the WUNTRACED option bit.
1280N/A */
1280N/A struct {
1280N/A#if defined(_LITTLE_ENDIAN)
1280N/A unsigned short w_Stopval:8; /* == W_STOPPED if stopped */
1280N/A unsigned short w_Stopsig:8; /* signal that stopped us */
1280N/A#elif defined(_BIG_ENDIAN)
1280N/A unsigned short w_Fill2:16; /* high 16 bits unused */
1280N/A unsigned short w_Stopsig:8; /* signal that stopped us */
1280N/A unsigned short w_Stopval:8; /* == W_STOPPED if stopped */
1280N/A#else
1280N/A#error NO ENDIAN defined.
1280N/A#endif
1280N/A } w_S;
1280N/A};
1280N/A#define w_termsig w_T.w_Termsig
1280N/A#define w_coredump w_T.w_Coredump
1280N/A#define w_retcode w_T.w_Retcode
1280N/A#define w_stopval w_S.w_Stopval
1280N/A#define w_stopsig w_S.w_Stopsig
1280N/A
1280N/A
1280N/A#define WSTOPPED 0177 /* value of s.stopval if process is stopped */
1280N/A#define WCONTFLG 0177777 /* value of w.w_status due to SIGCONT, sysV */
1280N/A
1280N/A/*
1280N/A * Option bits for the second argument of wait3. WNOHANG causes the
1280N/A * wait to not hang if there are no stopped or terminated processes, rather
1280N/A * returning an error indication in this case (pid==0). WUNTRACED
1280N/A * indicates that the caller should receive status about untraced children
1280N/A * which stop due to signals. If children are stopped and a wait without
1280N/A * this option is done, it is as though they were still running... nothing
1280N/A * about them is returned.
1280N/A */
1280N/A#define WNOHANG 1 /* dont hang in wait */
1280N/A#define WUNTRACED 2 /* tell about stopped, untraced children */
1280N/A
1280N/A#define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED)
1280N/A#define WIFSIGNALED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig != 0)
1280N/A#define WIFEXITED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig == 0)
1280N/A
1280N/A#ifdef KERNEL
1280N/A/*
1280N/A * Arguments to wait4() system call, included here so it may be called by
1280N/A * other routines in the kernel
1280N/A */
1280N/Astruct wait4_args {
1280N/A int pid;
1280N/A union wait *status;
1280N/A int options;
1280N/A struct rusage *rusage;
1280N/A};
1280N/A#endif KERNEL
1280N/A
1280N/A#endif /*!_sys_wait_h*/
1280N/A