263 lines
5.5 KiB
HTML
263 lines
5.5 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of WAIT4</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>WAIT4</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2018-04-30<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
wait3, wait4 - wait for process to change state, BSD style
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>></B>
|
|
<B>#include <<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>></B>
|
|
<B>#include <<A HREF="file:///usr/include/sys/resource.h">sys/resource.h</A>></B>
|
|
<B>#include <<A HREF="file:///usr/include/sys/wait.h">sys/wait.h</A>></B>
|
|
|
|
<B>pid_t wait3(int *</B><I>wstatus</I><B>, int </B><I>options</I><B>,</B>
|
|
<B> struct rusage *</B><I>rusage</I><B>);</B>
|
|
|
|
<B>pid_t wait4(pid_t </B><I>pid</I><B>, int *</B><I>wstatus</I><B>, int </B><I>options</I><B>,</B>
|
|
<B> struct rusage *</B><I>rusage</I><B>);</B>
|
|
</PRE>
|
|
|
|
<P>
|
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B>wait3</B>():
|
|
|
|
<BR> Since glibc 2.19:
|
|
<BR> _DEFAULT_SOURCE || _XOPEN_SOURCE >= 500
|
|
<BR> Glibc 2.19 and earlier:
|
|
<BR> _BSD_SOURCE || _XOPEN_SOURCE >= 500
|
|
|
|
<BR>
|
|
|
|
<B>wait4</B>():
|
|
|
|
<BR> Since glibc 2.19:
|
|
<BR> _DEFAULT_SOURCE
|
|
<BR> Glibc 2.19 and earlier:
|
|
<BR> _BSD_SOURCE
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
These functions are nonstandard; in new programs, the use of
|
|
<B><A HREF="/cgi-bin/man/man2html?2+waitpid">waitpid</A></B>(2)
|
|
|
|
or
|
|
<B><A HREF="/cgi-bin/man/man2html?2+waitid">waitid</A></B>(2)
|
|
|
|
is preferable.
|
|
<P>
|
|
|
|
The
|
|
<B>wait3</B>()
|
|
|
|
and
|
|
<B>wait4</B>()
|
|
|
|
system calls are similar to
|
|
<B><A HREF="/cgi-bin/man/man2html?2+waitpid">waitpid</A></B>(2),
|
|
|
|
but additionally return resource usage information about the
|
|
child in the structure pointed to by
|
|
<I>rusage</I>.
|
|
|
|
<P>
|
|
|
|
Other than the use of the
|
|
<I>rusage</I>
|
|
|
|
argument, the following
|
|
<B>wait3</B>()
|
|
|
|
call:
|
|
<P>
|
|
|
|
|
|
|
|
wait3(wstatus, options, rusage);
|
|
|
|
|
|
<P>
|
|
|
|
is equivalent to:
|
|
<P>
|
|
|
|
|
|
|
|
waitpid(-1, wstatus, options);
|
|
|
|
|
|
<P>
|
|
|
|
Similarly, the following
|
|
<B>wait4</B>()
|
|
|
|
call:
|
|
<P>
|
|
|
|
|
|
|
|
wait4(pid, wstatus, options, rusage);
|
|
|
|
|
|
<P>
|
|
|
|
is equivalent to:
|
|
<P>
|
|
|
|
|
|
|
|
waitpid(pid, wstatus, options);
|
|
|
|
|
|
<P>
|
|
|
|
In other words,
|
|
<B>wait3</B>()
|
|
|
|
waits of any child, while
|
|
<B>wait4</B>()
|
|
|
|
can be used to select a specific child, or children, on which to wait.
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?2+wait">wait</A></B>(2)
|
|
|
|
for further details.
|
|
<P>
|
|
|
|
If
|
|
<I>rusage</I>
|
|
|
|
is not NULL, the
|
|
<I>struct rusage</I>
|
|
|
|
to which it points will be filled with accounting information
|
|
about the child.
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getrusage">getrusage</A></B>(2)
|
|
|
|
for details.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
As for
|
|
<B><A HREF="/cgi-bin/man/man2html?2+waitpid">waitpid</A></B>(2).
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
As for
|
|
<B><A HREF="/cgi-bin/man/man2html?2+waitpid">waitpid</A></B>(2).
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
4.3BSD.
|
|
<P>
|
|
|
|
SUSv1 included a specification of
|
|
<B>wait3</B>();
|
|
|
|
SUSv2 included
|
|
<B>wait3</B>(),
|
|
|
|
but marked it LEGACY;
|
|
SUSv3 removed it.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
Including
|
|
<I><<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>></I>
|
|
|
|
is not required these days, but increases portability.
|
|
(Indeed,
|
|
<I><<A HREF="file:///usr/include/sys/resource.h">sys/resource.h</A>></I>
|
|
|
|
defines the
|
|
<I>rusage</I>
|
|
|
|
structure with fields of type
|
|
<I>struct timeval</I>
|
|
|
|
defined in
|
|
<I><<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>></I>.)
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H3>C library/kernel differences</H3>
|
|
|
|
On Linux,
|
|
<B>wait3</B>()
|
|
|
|
is a library function implemented on top of the
|
|
<B>wait4</B>()
|
|
|
|
system call.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+fork">fork</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getrusage">getrusage</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+sigaction">sigaction</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+signal">signal</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+wait">wait</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+signal">signal</A></B>(7)
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DL>
|
|
<DT id="8"><A HREF="#lbAI">C library/kernel differences</A><DD>
|
|
</DL>
|
|
<DT id="9"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
<DT id="10"><A HREF="#lbAK">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:35 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|