Mercurial > hg > octave-nkf > gnulib-hg
view tests/test-sys_wait.c @ 13682:9c6f4459f53d
stdlib: work around MirBSD WEXITSTATUS bug
* lib/stdlib.in.h (includes): Guarantee WEXITSTATUS.
* modules/stdlib (Depends-on): Add sys_wait.
* tests/test-sys_wait.c (main): Enhance test.
* tests/test-stdlib.c (main): Likewise.
* doc/posix-headers/stdlib.texi (stdlib.h): Document the bug.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Wed, 15 Sep 2010 15:25:43 -0600 |
parents | c2cbabec01dd |
children | 700156212a0d |
line wrap: on
line source
/* Test of <sys/wait.h> substitute. Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Written by Eric Blake <ebb9@byu.net>, 2009. */ #include <config.h> #include <sys/wait.h> /* Check for existence of required types. */ static pid_t a; int main (void) { /* Check for existence of required macros. Note that we document that these are safe only on lvalues. */ int i; for (i = 0; i < 0x10000; i = (i ? i << 1 : 1)) if (!!WIFSIGNALED (i) + !!WIFEXITED (i) + !!WIFSTOPPED (i) != 1) return 1; i = WEXITSTATUS (i) + WSTOPSIG (i) + WTERMSIG (i); switch (i) { #if 0 /* Gnulib doesn't guarantee these, yet. */ case WCONTINUED: case WNOHANG: case WUNTRACED: case WEXITED: case WNOWAIT: case WSTOPPED: #endif break; } return a ? i : 0; }