1 /* Test of <sys/wait.h> substitute.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 /* Written by Eric Blake <ebb9@byu.net>, 2009. */
23 /* Check for existence of required types. */
29 /* Check for existence of required macros. Note that we document
30 that these are safe only on lvalues. */
32 for (i = 0; i < 0x10000; i = (i ? i << 1 : 1))
34 /* POSIX requires that for all valid process statuses, that
35 exactly one of these three macros is true. But not all
36 possible 16-bit values map to valid process status.
37 Traditionally, 8 of the bits are for WIFEXITED, 7 of the bits
38 to tell between WIFSIGNALED and WIFSTOPPED, and either 0x80
39 or 0x8000 to flag that core was also dumped. Since we don't
40 know which byte is WIFEXITED, we skip the both possible bits
41 that can signal core dump. */
44 if (!!WIFSIGNALED (i) + !!WIFEXITED (i) + !!WIFSTOPPED (i) != 1)
47 i = WEXITSTATUS (i) + WSTOPSIG (i) + WTERMSIG (i);
52 /* Gnulib doesn't guarantee these, yet. */