man-pages/man2/wait4.2.html
2021-03-31 01:06:50 +01:00

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">&nbsp;</A>
<H2>NAME</H2>
wait3, wait4 - wait for process to change state, BSD style
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>&gt;</B>
<B>#include &lt;<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>&gt;</B>
<B>#include &lt;<A HREF="file:///usr/include/sys/resource.h">sys/resource.h</A>&gt;</B>
<B>#include &lt;<A HREF="file:///usr/include/sys/wait.h">sys/wait.h</A>&gt;</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>&nbsp;&nbsp;&nbsp;&nbsp;Since&nbsp;glibc&nbsp;2.19:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_DEFAULT_SOURCE&nbsp;||&nbsp;_XOPEN_SOURCE&nbsp;&gt;=&nbsp;500
<BR>&nbsp;&nbsp;&nbsp;&nbsp;Glibc&nbsp;2.19&nbsp;and&nbsp;earlier:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_BSD_SOURCE&nbsp;||&nbsp;_XOPEN_SOURCE&nbsp;&gt;=&nbsp;500
<BR>
<B>wait4</B>():
<BR>&nbsp;&nbsp;&nbsp;&nbsp;Since&nbsp;glibc&nbsp;2.19:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_DEFAULT_SOURCE
<BR>&nbsp;&nbsp;&nbsp;&nbsp;Glibc&nbsp;2.19&nbsp;and&nbsp;earlier:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_BSD_SOURCE
<A NAME="lbAD">&nbsp;</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">&nbsp;</A>
<H2>RETURN VALUE</H2>
As for
<B><A HREF="/cgi-bin/man/man2html?2+waitpid">waitpid</A></B>(2).
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
As for
<B><A HREF="/cgi-bin/man/man2html?2+waitpid">waitpid</A></B>(2).
<A NAME="lbAG">&nbsp;</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">&nbsp;</A>
<H2>NOTES</H2>
Including
<I>&lt;<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>&gt;</I>
is not required these days, but increases portability.
(Indeed,
<I>&lt;<A HREF="file:///usr/include/sys/resource.h">sys/resource.h</A>&gt;</I>
defines the
<I>rusage</I>
structure with fields of type
<I>struct timeval</I>
defined in
<I>&lt;<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>&gt;</I>.)
<A NAME="lbAI">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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>