2N/A/* A POSIX-like <sys/wait.h>.
2N/A Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc.
2N/A
2N/A This program is free software; you can redistribute it and/or modify
2N/A it under the terms of the GNU General Public License as published by
2N/A the Free Software Foundation; either version 3, or (at your option)
2N/A any later version.
2N/A
2N/A This program is distributed in the hope that it will be useful,
2N/A but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A GNU General Public License for more details.
2N/A
2N/A You should have received a copy of the GNU General Public License
2N/A along with this program; if not, write to the Free Software Foundation,
2N/A Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
2N/A
2N/A
2N/A#ifndef _GL_SYS_WAIT_H
2N/A
2N/A#if __GNUC__ >= 3
2N/A@PRAGMA_SYSTEM_HEADER@
2N/A#endif
2N/A
2N/A/* The include_next requires a split double-inclusion guard. */
2N/A#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
2N/A# @INCLUDE_NEXT@ @NEXT_SYS_WAIT_H@
2N/A#endif
2N/A
2N/A#ifndef _GL_SYS_WAIT_H
2N/A#define _GL_SYS_WAIT_H
2N/A
2N/A#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
2N/A/* Unix API. */
2N/A
2N/A/* The following macros apply to an argument x, that is a status of a process,
2N/A as returned by waitpid().
2N/A On nearly all systems, including Linux/x86, WEXITSTATUS are bits 15..8 and
2N/A WTERMSIG are bits 7..0, while BeOS uses the opposite. Therefore programs
2N/A have to use the abstract macros. */
2N/A
2N/A/* For valid x, exactly one of WIFSIGNALED(x), WIFEXITED(x), WIFSTOPPED(x)
2N/A is true. */
2N/A# ifndef WIFSIGNALED
2N/A# define WIFSIGNALED(x) (WTERMSIG (x) != 0 && WTERMSIG(x) != 0x7f)
2N/A# endif
2N/A# ifndef WIFEXITED
2N/A# define WIFEXITED(x) (WTERMSIG (x) == 0)
2N/A# endif
2N/A# ifndef WIFSTOPPED
2N/A# define WIFSTOPPED(x) (WTERMSIG (x) == 0x7f)
2N/A# endif
2N/A
2N/A/* The termination signal. Only to be accessed if WIFSIGNALED(x) is true. */
2N/A# ifndef WTERMSIG
2N/A# define WTERMSIG(x) ((x) & 0x7f)
2N/A# endif
2N/A
2N/A/* The exit status. Only to be accessed if WIFEXITED(x) is true. */
2N/A# ifndef WEXITSTATUS
2N/A# define WEXITSTATUS(x) (((x) >> 8) & 0xff)
2N/A# endif
2N/A
2N/A/* True if the process dumped core. Not standardized by POSIX. */
2N/A# ifndef WCOREDUMP
2N/A# define WCOREDUMP(x) ((x) & 0x80)
2N/A# endif
2N/A
2N/A# ifdef __cplusplus
2N/Aextern "C" {
2N/A# endif
2N/A
2N/A/* Declarations of functions. */
2N/A
2N/A# ifdef __cplusplus
2N/A}
2N/A# endif
2N/A
2N/A#else
2N/A/* Native Windows API. */
2N/A
2N/A# include <process.h>
2N/A
2N/A# define waitpid(pid,statusp,options) _cwait (statusp, pid, WAIT_CHILD)
2N/A
2N/A/* The following macros apply to an argument x, that is a status of a process,
2N/A as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess().
2N/A This value is simply an 'int', not composed of bit fields. */
2N/A
2N/A/* When an unhandled fatal signal terminates a process, the exit code is 3. */
2N/A# define WIFSIGNALED(x) ((x) == 3)
2N/A# define WIFEXITED(x) ((x) != 3)
2N/A# define WIFSTOPPED(x) 0
2N/A
2N/A/* The signal that terminated a process is not known posthum. */
2N/A# define WTERMSIG(x) SIGTERM
2N/A
2N/A# define WEXITSTATUS(x) (x)
2N/A
2N/A/* There are no core dumps. */
2N/A# define WCOREDUMP(x) 0
2N/A
2N/A#endif
2N/A
2N/A#endif /* _GL_SYS_WAIT_H */
2N/A#endif /* _GL_SYS_WAIT_H */