root/maint/gnulib/tests/test-sys_wait.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. test_sys_wait_macros

   1 /* Test of macros shared between <sys/wait.h> and <stdlib.h>.
   2    Copyright (C) 2010-2021 Free Software Foundation, Inc.
   3 
   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.
   8 
   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.
  13 
  14    You should have received a copy of the GNU General Public License
  15    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
  16 
  17 /* Written by Eric Blake <ebb9@byu.net>, 2010.  */
  18 
  19 static int
  20 test_sys_wait_macros (void)
     /* [previous][next][first][last][top][bottom][index][help] */
  21 {
  22   /* Check subset of <sys/wait.h> macros that must be visible here.
  23      Note that some of these macros are only portable when operating
  24      on an lvalue.  */
  25   int i;
  26   for (i = 0; i < 0x8000; i = (i ? i << 1 : 1))
  27     {
  28       /* POSIX requires that for all valid process statuses, that
  29          exactly one of these three macros is true.  But not all
  30          possible 16-bit values map to valid process status.
  31          Traditionally, 8 of the bits are for WIFEXITED, 7 of the bits
  32          to tell between WIFSIGNALED and WIFSTOPPED, and either 0x80
  33          or 0x8000 to flag that core was also dumped.  Since we don't
  34          know which byte is WIFEXITED, we skip the both possible bits
  35          that can signal core dump.  */
  36       if (i == 0x80)
  37         continue;
  38       if (!!WIFSIGNALED (i) + !!WIFEXITED (i) + !!WIFSTOPPED (i) != 1)
  39         return 1;
  40     }
  41   i = WEXITSTATUS (i) + WSTOPSIG (i) + WTERMSIG (i);
  42 
  43   switch (i)
  44     {
  45 #if 0
  46   /* Gnulib doesn't guarantee these, yet.  */
  47     case WNOHANG:
  48     case WUNTRACED:
  49 #endif
  50       break;
  51     }
  52   return 0;
  53 }

/* [previous][next][first][last][top][bottom][index][help] */