|
Packit Service |
fdd496 |
/* Test of macros shared between <sys/wait.h> and <stdlib.h>.
|
|
Packit Service |
fdd496 |
Copyright (C) 2010-2017 Free Software Foundation, Inc.
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
This program is free software: you can redistribute it and/or modify
|
|
Packit Service |
fdd496 |
it under the terms of the GNU General Public License as published by
|
|
Packit Service |
fdd496 |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
fdd496 |
(at your option) any later version.
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
fdd496 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
fdd496 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
fdd496 |
GNU General Public License for more details.
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
You should have received a copy of the GNU General Public License
|
|
Packit Service |
fdd496 |
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
/* Written by Eric Blake <ebb9@byu.net>, 2010. */
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
static int
|
|
Packit Service |
fdd496 |
test_sys_wait_macros (void)
|
|
Packit Service |
fdd496 |
{
|
|
Packit Service |
fdd496 |
/* Check subset of <sys/wait.h> macros that must be visible here.
|
|
Packit Service |
fdd496 |
Note that some of these macros are only portable when operating
|
|
Packit Service |
fdd496 |
on an lvalue. */
|
|
Packit Service |
fdd496 |
int i;
|
|
Packit Service |
fdd496 |
for (i = 0; i < 0x8000; i = (i ? i << 1 : 1))
|
|
Packit Service |
fdd496 |
{
|
|
Packit Service |
fdd496 |
/* POSIX requires that for all valid process statuses, that
|
|
Packit Service |
fdd496 |
exactly one of these three macros is true. But not all
|
|
Packit Service |
fdd496 |
possible 16-bit values map to valid process status.
|
|
Packit Service |
fdd496 |
Traditionally, 8 of the bits are for WIFEXITED, 7 of the bits
|
|
Packit Service |
fdd496 |
to tell between WIFSIGNALED and WIFSTOPPED, and either 0x80
|
|
Packit Service |
fdd496 |
or 0x8000 to flag that core was also dumped. Since we don't
|
|
Packit Service |
fdd496 |
know which byte is WIFEXITED, we skip the both possible bits
|
|
Packit Service |
fdd496 |
that can signal core dump. */
|
|
Packit Service |
fdd496 |
if (i == 0x80)
|
|
Packit Service |
fdd496 |
continue;
|
|
Packit Service |
fdd496 |
if (!!WIFSIGNALED (i) + !!WIFEXITED (i) + !!WIFSTOPPED (i) != 1)
|
|
Packit Service |
fdd496 |
return 1;
|
|
Packit Service |
fdd496 |
}
|
|
Packit Service |
fdd496 |
i = WEXITSTATUS (i) + WSTOPSIG (i) + WTERMSIG (i);
|
|
Packit Service |
fdd496 |
|
|
Packit Service |
fdd496 |
switch (i)
|
|
Packit Service |
fdd496 |
{
|
|
Packit Service |
fdd496 |
#if 0
|
|
Packit Service |
fdd496 |
/* Gnulib doesn't guarantee these, yet. */
|
|
Packit Service |
fdd496 |
case WNOHANG:
|
|
Packit Service |
fdd496 |
case WUNTRACED:
|
|
Packit Service |
fdd496 |
#endif
|
|
Packit Service |
fdd496 |
break;
|
|
Packit Service |
fdd496 |
}
|
|
Packit Service |
fdd496 |
return 0;
|
|
Packit Service |
fdd496 |
}
|