exit - cause normal process termination


   #include <stdlib.h>

   void exit(int status);


   The  exit() function causes normal process termination and the value of
   status & 0377 is returned to the parent (see wait(2)).

   All functions registered with atexit(3) and on_exit(3) are  called,  in
   the  reverse  order  of their registration.  (It is possible for one of
   these  functions  to  use  atexit(3)  or  on_exit(3)  to  register   an
   additional  function  to  be  executed  during exit processing; the new
   registration is added to the front of the list of functions that remain
   to  be  called.)   If  one of these functions does not return (e.g., it
   calls _exit(2), or kills itself  with  a  signal),  then  none  of  the
   remaining   functions  is  called,  and  further  exit  processing  (in
   particular, flushing of stdio(3) streams) is abandoned.  If a  function
   has  been registered multiple times using atexit(3) or on_exit(3), then
   it is called as many times as it was registered.

   All open stdio(3) streams are flushed and  closed.   Files  created  by
   tmpfile(3) are removed.

   The  C standard specifies two constants, EXIT_SUCCESS and EXIT_FAILURE,
   that may be passed to exit() to  indicate  successful  or  unsuccessful
   termination, respectively.


   The exit() function does not return.


   For   an   explanation   of   the  terms  used  in  this  section,  see

   Interface  Attribute      Value               
   exit()     Thread safety  MT-Unsafe race:exit 
   The exit() function uses a global variable that is not protected, so it
   is not thread-safe.


   POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD.


   It  is  undefined what happens if one of the functions registered using
   atexit(3) and on_exit(3) calls either exit() or longjmp(3).  Note  that
   a  call  to execve(2) removes registrations created using atexit(3) and

   The use of EXIT_SUCCESS and EXIT_FAILURE is slightly more portable  (to
   non-UNIX  environments) than the use of 0 and some nonzero value like 1
   or -1.  In particular, VMS uses a different convention.

   BSD has attempted to standardize exit codes; see the file <sysexits.h>.

   After exit(), the  exit  status  must  be  transmitted  to  the  parent
   process.   There  are three cases.  If the parent has set SA_NOCLDWAIT,
   or has set the SIGCHLD handler to SIG_IGN, the status is discarded.  If
   the parent was waiting on the child, it is notified of the exit status.
   In both cases the exiting process dies immediately.  If the parent  has
   not  indicated that it is not interested in the exit status, but is not
   waiting, the exiting process turns into a "zombie"  process  (which  is
   nothing  but  a  container  for  the  single byte representing the exit
   status) so that the parent can learn the  exit  status  when  it  later
   calls one of the wait(2) functions.

   If  the implementation supports the SIGCHLD signal, this signal is sent
   to the parent.  If the parent has set  SA_NOCLDWAIT,  it  is  undefined
   whether a SIGCHLD signal is sent.

   If  the process is a session leader and its controlling terminal is the
   controlling  terminal  of  the  session,  then  each  process  in   the
   foreground  process group of this controlling terminal is sent a SIGHUP
   signal, and the terminal is disassociated from this  session,  allowing
   it to be acquired by a new controlling process.

   If  the  exit of the process causes a process group to become orphaned,
   and if any member of the newly orphaned process group is stopped,  then
   a  SIGHUP  signal  followed  by  a  SIGCONT signal will be sent to each
   process in this process group.  See setpgid(2) for  an  explanation  of
   orphaned process groups.


   _exit(2), setpgid(2), wait(2), atexit(3), on_exit(3), tmpfile(3)


   This  page  is  part of release 4.09 of the Linux man-pages project.  A
   description of the project, information about reporting bugs,  and  the
   latest     version     of     this    page,    can    be    found    at


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.

Free Software

Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.

Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.

Free Books

The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.

Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.

Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.