⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wait.2

📁 Unix操作系统minix 2.0源码
💻 2
字号:
.\" Copyright (c) 1980 Regents of the University of California..\" All rights reserved.  The Berkeley software License Agreement.\" specifies the terms and conditions for redistribution..\".\"	@(#)wait.2	6.2 (Berkeley) 6/30/85.\".TH WAIT 2 "June 30, 1985".UC 4.SH NAMEwait, waitpid \- wait for process to terminate.SH SYNOPSIS.ft B.nf#include <sys/types.h>#include <sys/wait.h>pid_t wait(int *\fIstatus\fP)pid_t waitpid(pid_t \fIpid\fP, int *\fIstatus\fP, int \fIoptions\fP).fi.SH DESCRIPTION.B Waitcauses its caller to delay until a signal is received orone of its childprocesses terminates.If any child has died since the last.BR wait ,return is immediate, returning the process id andexit status of one of the terminatedchildren.If there are no children, return is immediate withthe value \-1 returned..PPOn return from a successful .B waitcall, .I statusis nonzero, and the high byte of .I statuscontains the low byte of the argument to.B exitsupplied by the child process;the low byte of .I statuscontains the termination status of the process.A more precise definition of the.I statusword is given in.RI < sys/wait.h >.If.B waitcan called with a null pointer argument to indicate that no status needbe returned..PP.B Waitpidprovides an alternate interface for programsthat must not block when collecting the statusof child processes, or that wish to wait forone particular child.  The pid parameter isthe process ID of the child to wait for, \-1for any child.  The.I statusparameter is defined as above.  The.I optionsparameter is used to indicate the call should not block ifthere are no processes that wish to report status (WNOHANG),and/or that children of the current process that are stoppeddue to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal should also havetheir status reported (WUNTRACED).  (Job control is not implemented forMinix, but these symbold and signals are.).PPWhen the WNOHANG option is specified and no processeswish to report status, .B waitpidreturns \-1 with.B errnoset to.BR EAGAIN .The WNOHANG and WUNTRACED options may be combined by .IR or 'ingthe two values..SH NOTESThe call.BI "wait(&" status ")"is equivalent to.BI "waitpid(\-1, &" status ", 0)\fR.".PPSee.BR sigaction (2)for a list of termination statuses (signals);0 status indicates normal termination.A special status (0177) is returned for a stopped processthat has not terminated and can be restarted;see.BR ptrace (2).If the 0200 bit of the termination statusis set,a core image of the process was producedby the system..PPIf the parent process terminates withoutwaiting on its children,the initialization process(process ID = 1)inherits the children..PP.I <sys/wait.h>defines a number of macros that operate on a status word:.TP 5.BI "WIFEXITED(" status ")"True if normal exit..TP 5.BI "WEXITSTATUS(" status ")"Exit status if the process returned by a normal exit, zero otherwise..TP 5.BI "WTERMSIG(" status ")"Signal number if the process died by a signal, zero otherwise..TP 5.BI "WIFSIGNALED(" status ")"True if the process died by a signal..TP 5.BI "WIFSTOPPED(" status ")"True if the process is stopped.  (Never true under Minix.).TP 5.BI "WSTOPSIG(" status ")"Signal number of the signal that stopped the process..SH "RETURN VALUEIf \fBwait\fP returns due to a stoppedor terminated child process, the process ID of the childis returned to the calling process.  Otherwise, a value of \-1is returned and \fBerrno\fP is set to indicate the error..PP.B Waitpidreturns \-1 if there are no children not previously waited for, ifthe process that it wants to wait for doesn't exist, or ifWNOHANG is specified and there are no stopped or exited children..SH ERRORS.B Waitwill fail and return immediately if one or more of the followingare true:.TP 15[ECHILD]The calling process has no existing unwaited-forchild processes..TP 15[EFAULT]The \fIstatus\fP argument points to an illegal address..TP 15[EAGAIN].B Waitpidis called with the WNOHANG option and no child has exited yet..SH "SEE ALSO".BR execve (2),.BR exit (2),.BR sigaction (2).

⌨️ 快捷键说明

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