Blame posix/sys/wait.h

Packit 6c4009
/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 *	POSIX Standard: 3.2.1 Wait for Process Termination	<sys/wait.h>
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#ifndef	_SYS_WAIT_H
Packit 6c4009
#define	_SYS_WAIT_H	1
Packit 6c4009
Packit 6c4009
#include <features.h>
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
#include <bits/types.h>
Packit 6c4009
#ifndef __pid_t_defined
Packit 6c4009
typedef __pid_t pid_t;
Packit 6c4009
# define __pid_t_defined
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
Packit 6c4009
# include <signal.h>
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8
Packit 6c4009
/* Some older standards require the contents of struct rusage to be
Packit 6c4009
   defined here.  */
Packit 6c4009
# include <bits/types/struct_rusage.h>
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* These macros could also be defined in <stdlib.h>.  */
Packit 6c4009
#if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8)
Packit 6c4009
/* This will define the `W*' macros for the flag
Packit 6c4009
   bits to `waitpid', `wait3', and `wait4'.  */
Packit 6c4009
# include <bits/waitflags.h>
Packit 6c4009
Packit 6c4009
/* This will define all the `__W*' macros.  */
Packit 6c4009
# include <bits/waitstatus.h>
Packit 6c4009
Packit 6c4009
# define WEXITSTATUS(status)	__WEXITSTATUS (status)
Packit 6c4009
# define WTERMSIG(status)	__WTERMSIG (status)
Packit 6c4009
# define WSTOPSIG(status)	__WSTOPSIG (status)
Packit 6c4009
# define WIFEXITED(status)	__WIFEXITED (status)
Packit 6c4009
# define WIFSIGNALED(status)	__WIFSIGNALED (status)
Packit 6c4009
# define WIFSTOPPED(status)	__WIFSTOPPED (status)
Packit 6c4009
# ifdef __WIFCONTINUED
Packit 6c4009
#  define WIFCONTINUED(status)	__WIFCONTINUED (status)
Packit 6c4009
# endif
Packit 6c4009
#endif	/* <stdlib.h> not included.  */
Packit 6c4009
Packit 6c4009
#ifdef	__USE_MISC
Packit 6c4009
# define WCOREFLAG		__WCOREFLAG
Packit 6c4009
# define WCOREDUMP(status)	__WCOREDUMP (status)
Packit 6c4009
# define W_EXITCODE(ret, sig)	__W_EXITCODE (ret, sig)
Packit 6c4009
# define W_STOPCODE(sig)	__W_STOPCODE (sig)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* The following values are used by the `waitid' function.  */
Packit 6c4009
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
Packit 6c4009
typedef enum
Packit 6c4009
{
Packit 6c4009
  P_ALL,		/* Wait for any child.  */
Packit 6c4009
  P_PID,		/* Wait for specified process.  */
Packit 6c4009
  P_PGID		/* Wait for members of process group.  */
Packit 6c4009
} idtype_t;
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Wait for a child to die.  When one does, put its status in *STAT_LOC
Packit 6c4009
   and return its process ID.  For errors, return (pid_t) -1.
Packit 6c4009
Packit 6c4009
   This function is a cancellation point and therefore not marked with
Packit 6c4009
   __THROW.  */
Packit 6c4009
extern __pid_t wait (int *__stat_loc);
Packit 6c4009
Packit 6c4009
#ifdef	__USE_MISC
Packit 6c4009
/* Special values for the PID argument to `waitpid' and `wait4'.  */
Packit 6c4009
# define WAIT_ANY	(-1)	/* Any process.  */
Packit 6c4009
# define WAIT_MYPGRP	0	/* Any process in my process group.  */
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Wait for a child matching PID to die.
Packit 6c4009
   If PID is greater than 0, match any process whose process ID is PID.
Packit 6c4009
   If PID is (pid_t) -1, match any process.
Packit 6c4009
   If PID is (pid_t) 0, match any process with the
Packit 6c4009
   same process group as the current process.
Packit 6c4009
   If PID is less than -1, match any process whose
Packit 6c4009
   process group is the absolute value of PID.
Packit 6c4009
   If the WNOHANG bit is set in OPTIONS, and that child
Packit 6c4009
   is not already dead, return (pid_t) 0.  If successful,
Packit 6c4009
   return PID and store the dead child's status in STAT_LOC.
Packit 6c4009
   Return (pid_t) -1 for errors.  If the WUNTRACED bit is
Packit 6c4009
   set in OPTIONS, return status for stopped children; otherwise don't.
Packit 6c4009
Packit 6c4009
   This function is a cancellation point and therefore not marked with
Packit 6c4009
   __THROW.  */
Packit 6c4009
extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
Packit 6c4009
Packit 6c4009
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
Packit 6c4009
# ifndef __id_t_defined
Packit 6c4009
typedef __id_t id_t;
Packit 6c4009
#  define __id_t_defined
Packit 6c4009
# endif
Packit 6c4009
Packit 6c4009
# include <bits/types/siginfo_t.h>
Packit 6c4009
Packit 6c4009
/* Wait for a childing matching IDTYPE and ID to change the status and
Packit 6c4009
   place appropriate information in *INFOP.
Packit 6c4009
   If IDTYPE is P_PID, match any process whose process ID is ID.
Packit 6c4009
   If IDTYPE is P_PGID, match any process whose process group is ID.
Packit 6c4009
   If IDTYPE is P_ALL, match any process.
Packit 6c4009
   If the WNOHANG bit is set in OPTIONS, and that child
Packit 6c4009
   is not already dead, clear *INFOP and return 0.  If successful, store
Packit 6c4009
   exit code and status in *INFOP.
Packit 6c4009
Packit 6c4009
   This function is a cancellation point and therefore not marked with
Packit 6c4009
   __THROW.  */
Packit 6c4009
extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
Packit 6c4009
		   int __options);
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#if defined __USE_MISC \
Packit 6c4009
    || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K)
Packit 6c4009
/* This being here makes the prototypes valid whether or not
Packit 6c4009
   we have already included <sys/resource.h> to define `struct rusage'.  */
Packit 6c4009
struct rusage;
Packit 6c4009
Packit 6c4009
/* Wait for a child to exit.  When one does, put its status in *STAT_LOC and
Packit 6c4009
   return its process ID.  For errors return (pid_t) -1.  If USAGE is not
Packit 6c4009
   nil, store information about the child's resource usage there.  If the
Packit 6c4009
   WUNTRACED bit is set in OPTIONS, return status for stopped children;
Packit 6c4009
   otherwise don't.  */
Packit 6c4009
extern __pid_t wait3 (int *__stat_loc, int __options,
Packit 6c4009
		      struct rusage * __usage) __THROWNL;
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef __USE_MISC
Packit 6c4009
/* PID is like waitpid.  Other args are like wait3.  */
Packit 6c4009
extern __pid_t wait4 (__pid_t __pid, int *__stat_loc, int __options,
Packit 6c4009
		      struct rusage *__usage) __THROWNL;
Packit 6c4009
#endif /* Use misc.  */
Packit 6c4009
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif /* sys/wait.h  */