xref: /netbsd-src/external/gpl2/xcvs/dist/lib/wait.h (revision a7c918477dd5f12c1da816ba05caf44eab2d06d6)
1*a7c91847Schristos /* wait.h -- POSIX macros for evaluating exit statuses
2*a7c91847Schristos    Copyright (C) 1990 Free Software Foundation, Inc.
3*a7c91847Schristos 
4*a7c91847Schristos    This program is free software; you can redistribute it and/or modify
5*a7c91847Schristos    it under the terms of the GNU General Public License as published by
6*a7c91847Schristos    the Free Software Foundation; either version 2, or (at your option)
7*a7c91847Schristos    any later version.
8*a7c91847Schristos 
9*a7c91847Schristos    This program is distributed in the hope that it will be useful,
10*a7c91847Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
11*a7c91847Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*a7c91847Schristos    GNU General Public License for more details.  */
13*a7c91847Schristos 
14*a7c91847Schristos #ifdef HAVE_SYS_WAIT_H
15*a7c91847Schristos #include <sys/types.h>		/* For pid_t. */
16*a7c91847Schristos #ifdef HAVE_SYS_RESOURCE_H
17*a7c91847Schristos #include <sys/resource.h>	/* for rusage */
18*a7c91847Schristos #endif
19*a7c91847Schristos #include <sys/wait.h>
20*a7c91847Schristos #endif
21*a7c91847Schristos #ifndef WIFSTOPPED
22*a7c91847Schristos #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
23*a7c91847Schristos #endif
24*a7c91847Schristos #ifndef WIFSIGNALED
25*a7c91847Schristos #define WIFSIGNALED(w) (((w) & 0xff) != 0x7f && ((w) & 0xff) != 0)
26*a7c91847Schristos #endif
27*a7c91847Schristos #ifndef WIFEXITED
28*a7c91847Schristos #define WIFEXITED(w) (((w) & 0xff) == 0)
29*a7c91847Schristos #endif
30*a7c91847Schristos #ifndef WCOREDUMP	/* not POSIX, but common and useful */
31*a7c91847Schristos #define WCOREDUMP(w) (((w) & 0x80) != 0)
32*a7c91847Schristos #endif
33*a7c91847Schristos 
34*a7c91847Schristos #ifndef WSTOPSIG
35*a7c91847Schristos #define WSTOPSIG(w) (((w) >> 8) & 0xff)
36*a7c91847Schristos #endif
37*a7c91847Schristos #ifndef WTERMSIG
38*a7c91847Schristos #define WTERMSIG(w) ((w) & 0x7f)
39*a7c91847Schristos #endif
40*a7c91847Schristos #ifndef WEXITSTATUS
41*a7c91847Schristos #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
42*a7c91847Schristos #endif
43