212 lines
5.0 KiB
HTML
212 lines
5.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of _EXIT</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>_EXIT</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2020-02-09<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>
|
|
|
|
_exit, _Exit - terminate the calling process
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/unistd.h">unistd.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>void _exit(int </B><I>status</I><B>);</B>
|
|
|
|
<P>
|
|
<B>#include <<A HREF="file:///usr/include/stdlib.h">stdlib.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>void _Exit(int </B><I>status</I><B>);</B>
|
|
|
|
<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>_Exit</B>():
|
|
|
|
<DL COMPACT><DT id="1"><DD>
|
|
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|
|
</DL>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The function
|
|
<B>_exit</B>()
|
|
|
|
terminates the calling process "immediately".
|
|
Any open file descriptors belonging to the process are closed.
|
|
Any children of the process are inherited by
|
|
<B><A HREF="/cgi-bin/man/man2html?1+init">init</A></B>(1)
|
|
|
|
(or by the nearest "subreaper" process as defined through the use of the
|
|
<B><A HREF="/cgi-bin/man/man2html?2+prctl">prctl</A></B>(2)
|
|
|
|
<B>PR_SET_CHILD_SUBREAPER</B>
|
|
|
|
operation).
|
|
The process's parent is sent a
|
|
<B>SIGCHLD</B>
|
|
|
|
signal.
|
|
<P>
|
|
|
|
The value
|
|
<I>status & 0xFF</I>
|
|
|
|
is returned to the parent process as the process's exit status, and
|
|
can be collected using one of the
|
|
<B><A HREF="/cgi-bin/man/man2html?2+wait">wait</A></B>(2)
|
|
|
|
family of calls.
|
|
<P>
|
|
|
|
The function
|
|
<B>_Exit</B>()
|
|
|
|
is equivalent to
|
|
<B>_exit</B>().
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
These functions do not return.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
|
|
The function
|
|
<B>_Exit</B>()
|
|
|
|
was introduced by C99.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
For a discussion on the effects of an exit, the transmission of
|
|
exit status, zombie processes, signals sent, and so on, see
|
|
<B><A HREF="/cgi-bin/man/man2html?3+exit">exit</A></B>(3).
|
|
|
|
<P>
|
|
|
|
The function
|
|
<B>_exit</B>()
|
|
|
|
is like
|
|
<B><A HREF="/cgi-bin/man/man2html?3+exit">exit</A></B>(3),
|
|
|
|
but does not call any
|
|
functions registered with
|
|
<B><A HREF="/cgi-bin/man/man2html?3+atexit">atexit</A></B>(3)
|
|
|
|
or
|
|
<B><A HREF="/cgi-bin/man/man2html?3+on_exit">on_exit</A></B>(3).
|
|
|
|
Open
|
|
<B><A HREF="/cgi-bin/man/man2html?3+stdio">stdio</A></B>(3)
|
|
|
|
streams are not flushed.
|
|
On the other hand,
|
|
<B>_exit</B>()
|
|
|
|
does close open file descriptors, and this may cause an unknown delay,
|
|
waiting for pending output to finish.
|
|
If the delay is undesired,
|
|
it may be useful to call functions like
|
|
<B><A HREF="/cgi-bin/man/man2html?3+tcflush">tcflush</A></B>(3)
|
|
|
|
before calling
|
|
<B>_exit</B>().
|
|
|
|
Whether any pending I/O is canceled, and which pending I/O may be
|
|
canceled upon
|
|
<B>_exit</B>(),
|
|
|
|
is implementation-dependent.
|
|
<A NAME="lbAH"> </A>
|
|
<H3>C library/kernel differences</H3>
|
|
|
|
In glibc up to version 2.3, the
|
|
<B>_exit</B>()
|
|
|
|
wrapper function invoked the kernel system call of the same name.
|
|
Since glibc 2.3, the wrapper function invokes
|
|
<B><A HREF="/cgi-bin/man/man2html?2+exit_group">exit_group</A></B>(2),
|
|
|
|
in order to terminate all of the threads in a process.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+execve">execve</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+exit_group">exit_group</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+fork">fork</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+kill">kill</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+wait">wait</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+wait4">wait4</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+waitpid">waitpid</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+atexit">atexit</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+exit">exit</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+on_exit">on_exit</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+termios">termios</A></B>(3)
|
|
|
|
<A NAME="lbAJ"> </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="2"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="3"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="4"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="5"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="6"><A HREF="#lbAF">CONFORMING TO</A><DD>
|
|
<DT id="7"><A HREF="#lbAG">NOTES</A><DD>
|
|
<DL>
|
|
<DT id="8"><A HREF="#lbAH">C library/kernel differences</A><DD>
|
|
</DL>
|
|
<DT id="9"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="10"><A HREF="#lbAJ">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:32 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|