1da2e3ebchin/***********************************************************************
2da2e3ebchin*                                                                      *
3da2e3ebchin*               This software is part of the ast package               *
43e14f97Roger A. Faulkner*          Copyright (c) 1985-2010 AT&T Intellectual Property          *
5da2e3ebchin*                      and is licensed under the                       *
6da2e3ebchin*                  Common Public License, Version 1.0                  *
77c2fbfbApril Chin*                    by AT&T Intellectual Property                     *
8da2e3ebchin*                                                                      *
9da2e3ebchin*                A copy of the License is available at                 *
10da2e3ebchin*            http://www.opensource.org/licenses/cpl1.0.txt             *
11da2e3ebchin*         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12da2e3ebchin*                                                                      *
13da2e3ebchin*              Information and Software Systems Research               *
14da2e3ebchin*                            AT&T Research                             *
15da2e3ebchin*                           Florham Park NJ                            *
16da2e3ebchin*                                                                      *
17da2e3ebchin*                 Glenn Fowler <gsf@research.att.com>                  *
18da2e3ebchin*                  David Korn <dgk@research.att.com>                   *
19da2e3ebchin*                   Phong Vo <kpv@research.att.com>                    *
20da2e3ebchin*                                                                      *
21da2e3ebchin***********************************************************************/
22da2e3ebchin#pragma prototyped
23da2e3ebchin/*
24da2e3ebchin * ast POSIX wait/exit support
25da2e3ebchin */
26da2e3ebchin
27da2e3ebchin#ifndef _WAIT_H
28da2e3ebchin#define _WAIT_H
29da2e3ebchin
30da2e3ebchin#include <ast.h>
31da2e3ebchin#include <ast_wait.h>
32da2e3ebchin
33da2e3ebchin#if _sys_wait
34da2e3ebchin#if defined(__STDPP__directive) && defined(__STDPP__hide)
35da2e3ebchin__STDPP__directive pragma pp:hide wait waitpid
36da2e3ebchin#else
37da2e3ebchin#define wait		______wait
38da2e3ebchin#define waitpid		______waitpid
39da2e3ebchin#endif
40da2e3ebchin#include <sys/wait.h>
41da2e3ebchin#if defined(__STDPP__directive) && defined(__STDPP__hide)
42da2e3ebchin__STDPP__directive pragma pp:nohide wait waitpid
43da2e3ebchin#else
44da2e3ebchin#undef	wait
45da2e3ebchin#undef	waitpid
46da2e3ebchin#endif
47da2e3ebchin#endif
48da2e3ebchin
49da2e3ebchin#ifndef WNOHANG
50da2e3ebchin#define WNOHANG		1
51da2e3ebchin#endif
52da2e3ebchin
53da2e3ebchin#ifndef WUNTRACED
54da2e3ebchin#define WUNTRACED	2
55da2e3ebchin#endif
56da2e3ebchin
57da2e3ebchin#if !_ok_wif
58da2e3ebchin#undef	WIFEXITED
59da2e3ebchin#undef	WEXITSTATUS
60da2e3ebchin#undef	WIFSIGNALED
61da2e3ebchin#undef	WTERMSIG
62da2e3ebchin#undef	WIFSTOPPED
63da2e3ebchin#undef	WSTOPSIG
64da2e3ebchin#undef	WTERMCORE
65da2e3ebchin#endif
66da2e3ebchin
67da2e3ebchin#ifndef WIFEXITED
68da2e3ebchin#define WIFEXITED(x)	(!((x)&((1<<(EXIT_BITS-1))-1)))
69da2e3ebchin#endif
70da2e3ebchin
71da2e3ebchin#ifndef WEXITSTATUS
72da2e3ebchin#define WEXITSTATUS(x)	(((x)>>EXIT_BITS)&((1<<EXIT_BITS)-1))
73da2e3ebchin#endif
74da2e3ebchin
75da2e3ebchin#ifndef WIFSIGNALED
76da2e3ebchin#define WIFSIGNALED(x)	(((x)&((1<<(EXIT_BITS-1))-1))!=0)
77da2e3ebchin#endif
78da2e3ebchin
79da2e3ebchin#ifndef WTERMSIG
80da2e3ebchin#define WTERMSIG(x)	((x)&((1<<(EXIT_BITS-1))-1))
81da2e3ebchin#endif
82da2e3ebchin
83da2e3ebchin#ifndef WIFSTOPPED
84da2e3ebchin#define WIFSTOPPED(x)	(((x)&((1<<EXIT_BITS)-1))==((1<<(EXIT_BITS-1))-1))
85da2e3ebchin#endif
86da2e3ebchin
87da2e3ebchin#ifndef WSTOPSIG
88da2e3ebchin#define WSTOPSIG(x)	WEXITSTATUS(x)
89da2e3ebchin#endif
90da2e3ebchin
91da2e3ebchin#ifndef WTERMCORE
92da2e3ebchin#define WTERMCORE(x)	((x)&(1<<(EXIT_BITS-1)))
93da2e3ebchin#endif
94da2e3ebchin
95da2e3ebchinextern pid_t		wait(int*);
96da2e3ebchinextern pid_t		waitpid(pid_t, int*, int);
97da2e3ebchin
98da2e3ebchin#endif
99