Blame gnulib/lib/sys_wait.in.h

Packit eba2e2
/* A POSIX-like <sys/wait.h>.
Packit eba2e2
   Copyright (C) 2001-2003, 2005-2014 Free Software Foundation, Inc.
Packit eba2e2
Packit eba2e2
   This program is free software; you can redistribute it and/or modify
Packit eba2e2
   it under the terms of the GNU General Public License as published by
Packit eba2e2
   the Free Software Foundation; either version 3, or (at your option)
Packit eba2e2
   any later version.
Packit eba2e2
Packit eba2e2
   This program is distributed in the hope that it will be useful,
Packit eba2e2
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit eba2e2
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit eba2e2
   GNU General Public License for more details.
Packit eba2e2
Packit eba2e2
   You should have received a copy of the GNU General Public License
Packit eba2e2
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
Packit eba2e2
Packit eba2e2
Packit eba2e2
#ifndef _@GUARD_PREFIX@_SYS_WAIT_H
Packit eba2e2
Packit eba2e2
#if __GNUC__ >= 3
Packit eba2e2
@PRAGMA_SYSTEM_HEADER@
Packit eba2e2
#endif
Packit eba2e2
@PRAGMA_COLUMNS@
Packit eba2e2
Packit eba2e2
/* The include_next requires a split double-inclusion guard.  */
Packit eba2e2
#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
Packit eba2e2
# @INCLUDE_NEXT@ @NEXT_SYS_WAIT_H@
Packit eba2e2
#endif
Packit eba2e2
Packit eba2e2
#ifndef _@GUARD_PREFIX@_SYS_WAIT_H
Packit eba2e2
#define _@GUARD_PREFIX@_SYS_WAIT_H
Packit eba2e2
Packit eba2e2
/* Get pid_t.  */
Packit eba2e2
#include <sys/types.h>
Packit eba2e2
Packit eba2e2
Packit eba2e2
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
Packit eba2e2
Packit eba2e2
/* The definition of _GL_WARN_ON_USE is copied here.  */
Packit eba2e2
Packit eba2e2
Packit eba2e2
#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
Packit eba2e2
/* Unix API.  */
Packit eba2e2
Packit eba2e2
/* The following macros apply to an argument x, that is a status of a process,
Packit eba2e2
   as returned by waitpid().
Packit eba2e2
   On nearly all systems, including Linux/x86, WEXITSTATUS are bits 15..8 and
Packit eba2e2
   WTERMSIG are bits 7..0, while BeOS uses the opposite.  Therefore programs
Packit eba2e2
   have to use the abstract macros.  */
Packit eba2e2
Packit eba2e2
/* For valid x, exactly one of WIFSIGNALED(x), WIFEXITED(x), WIFSTOPPED(x)
Packit eba2e2
   is true.  */
Packit eba2e2
# ifndef WIFSIGNALED
Packit eba2e2
#  define WIFSIGNALED(x) (WTERMSIG (x) != 0 && WTERMSIG(x) != 0x7f)
Packit eba2e2
# endif
Packit eba2e2
# ifndef WIFEXITED
Packit eba2e2
#  define WIFEXITED(x) (WTERMSIG (x) == 0)
Packit eba2e2
# endif
Packit eba2e2
# ifndef WIFSTOPPED
Packit eba2e2
#  define WIFSTOPPED(x) (WTERMSIG (x) == 0x7f)
Packit eba2e2
# endif
Packit eba2e2
Packit eba2e2
/* The termination signal. Only to be accessed if WIFSIGNALED(x) is true.  */
Packit eba2e2
# ifndef WTERMSIG
Packit eba2e2
#  define WTERMSIG(x) ((x) & 0x7f)
Packit eba2e2
# endif
Packit eba2e2
Packit eba2e2
/* The exit status. Only to be accessed if WIFEXITED(x) is true.  */
Packit eba2e2
# ifndef WEXITSTATUS
Packit eba2e2
#  define WEXITSTATUS(x) (((x) >> 8) & 0xff)
Packit eba2e2
# endif
Packit eba2e2
Packit eba2e2
/* The stopping signal. Only to be accessed if WIFSTOPPED(x) is true.  */
Packit eba2e2
# ifndef WSTOPSIG
Packit eba2e2
#  define WSTOPSIG(x) (((x) >> 8) & 0x7f)
Packit eba2e2
# endif
Packit eba2e2
Packit eba2e2
/* True if the process dumped core.  Not standardized by POSIX.  */
Packit eba2e2
# ifndef WCOREDUMP
Packit eba2e2
#  define WCOREDUMP(x) ((x) & 0x80)
Packit eba2e2
# endif
Packit eba2e2
Packit eba2e2
#else
Packit eba2e2
/* Native Windows API.  */
Packit eba2e2
Packit eba2e2
# include <signal.h> /* for SIGTERM */
Packit eba2e2
Packit eba2e2
/* The following macros apply to an argument x, that is a status of a process,
Packit eba2e2
   as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess().
Packit eba2e2
   This value is simply an 'int', not composed of bit fields.  */
Packit eba2e2
Packit eba2e2
/* When an unhandled fatal signal terminates a process, the exit code is 3.  */
Packit eba2e2
# define WIFSIGNALED(x) ((x) == 3)
Packit eba2e2
# define WIFEXITED(x) ((x) != 3)
Packit eba2e2
# define WIFSTOPPED(x) 0
Packit eba2e2
Packit eba2e2
/* The signal that terminated a process is not known posthum.  */
Packit eba2e2
# define WTERMSIG(x) SIGTERM
Packit eba2e2
Packit eba2e2
# define WEXITSTATUS(x) (x)
Packit eba2e2
Packit eba2e2
/* There are no stopping signals.  */
Packit eba2e2
# define WSTOPSIG(x) 0
Packit eba2e2
Packit eba2e2
/* There are no core dumps.  */
Packit eba2e2
# define WCOREDUMP(x) 0
Packit eba2e2
Packit eba2e2
#endif
Packit eba2e2
Packit eba2e2
Packit eba2e2
/* Declarations of functions.  */
Packit eba2e2
Packit eba2e2
#if @GNULIB_WAITPID@
Packit eba2e2
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
Packit eba2e2
_GL_FUNCDECL_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
Packit eba2e2
# endif
Packit eba2e2
_GL_CXXALIAS_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
Packit eba2e2
_GL_CXXALIASWARN (waitpid);
Packit eba2e2
#elif defined GNULIB_POSIXCHECK
Packit eba2e2
# undef waitpid
Packit eba2e2
# if HAVE_RAW_DECL_WAITPID
Packit eba2e2
_GL_WARN_ON_USE (waitpid, "waitpid is unportable - "
Packit eba2e2
                 "use gnulib module sys_wait for portability");
Packit eba2e2
# endif
Packit eba2e2
#endif
Packit eba2e2
Packit eba2e2
Packit eba2e2
#endif /* _@GUARD_PREFIX@_SYS_WAIT_H */
Packit eba2e2
#endif /* _@GUARD_PREFIX@_SYS_WAIT_H */