wait.mh

来自「开放源码的编译器open watcom 1.6.0版的源代码」· MH 代码 · 共 73 行

MH
73
字号
/*
 *  sys/wait.h  POSIX Standard: 3.2.1 Wait for Process Termination
 *
:include crwat.sp
 */
#ifndef _SYS_WAIT_H_INCLUDED
#define _SYS_WAIT_H_INCLUDED
:include readonly.sp
:include cpluspro.sp
:include lnxkpack.sp

#include <signal.h>

/* From <bits/flags.h> */

/* Bits in the third argument to `waitpid'.  */
#define WNOHANG         1           /* Don't block waiting.  */
#define WUNTRACED       2           /* Report status of stopped children.  */

#define __WALL          0x40000000 /* Wait for any child.  */
#define __WCLONE        0x80000000 /* Wait for cloned process.  */

/* From <bits/waitstatus.h> */

#define __WEXITSTATUS(status)   (((status) & 0xff00) >> 8)
#define __WTERMSIG(status)      ((status) & 0x7f)
#define __WSTOPSIG(status)      __WEXITSTATUS(status)
#define __WIFEXITED(status)     (__WTERMSIG(status) == 0)
#define __WIFSIGNALED(status)   (!__WIFSTOPPED(status) && !__WIFEXITED(status))
#define __WIFSTOPPED(status)    (((status) & 0xff) == 0x7f)
#define __WCOREDUMP(status)     ((status) & __WCOREFLAG)
#define __W_EXITCODE(ret, sig)  ((ret) << 8 | (sig))
#define __W_STOPCODE(sig)       ((sig) << 8 | 0x7f)
#define __WCOREFLAG             0x80

/* Remainder of <sys/wait.h> */

#define __WAIT_INT(status)      (status)
#define __WAIT_STATUS           int *
#define __WAIT_STATUS_DEFN      int *

#define WEXITSTATUS(status)     __WEXITSTATUS(__WAIT_INT(status))
#define WTERMSIG(status)        __WTERMSIG(__WAIT_INT(status))
#define WSTOPSIG(status)        __WSTOPSIG(__WAIT_INT(status))
#define WIFEXITED(status)       __WIFEXITED(__WAIT_INT(status))
#define WIFSIGNALED(status)     __WIFSIGNALED(__WAIT_INT(status))
#define WIFSTOPPED(status)      __WIFSTOPPED(__WAIT_INT(status))

/* Wait for a child to die.  When one does, put its status in *STAT_LOC
 * and return its process ID.  For errors, return (pid_t) -1.
 */
_WCRTLINK extern pid_t wait( __WAIT_STATUS __stat_loc );

/* Wait for a child matching PID to die.
 * If PID is greater than 0, match any process whose process ID is PID.
 * If PID is (pid_t) -1, match any process.
 * If PID is (pid_t) 0, match any process with the
 * same process group as the current process.
 * If PID is less than -1, match any process whose
 * process group is the absolute value of PID.
 * If the WNOHANG bit is set in OPTIONS, and that child
 * is not already dead, return (pid_t) 0.  If successful,
 * return PID and store the dead child's status in STAT_LOC.
 * Return (pid_t) -1 for errors.  If the WUNTRACED bit is
 * set in OPTIONS, return status for stopped children; otherwise don't.
 */
_WCRTLINK extern pid_t waitpid( pid_t __pid, int *__stat_loc, int __options );

:include poppack.sp
:include cplusepi.sp
#endif /* !_SYS_WAIT_H_INCLUDED */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?