Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>exit() terminate process after cleanup</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
exit()                   Terminate Process after Cleanup

 #include   <process.h>                  Required for declarations only
 #include   <stdlib.h>                   Use either process.h or stdlib.h

 void       exit(status);
 int        status;                      Exit status

    exit() terminates the calling process and returns the low-byte of
    'status' (status & 0xFF) to the waiting parent process, if one
    exists.  Before terminating, all functions registered with ONEXIT are
    called in a "last-in, first-out" order, all stream buffers are
    flushed, and all files are closed.


     Return:    There is no return value; exit() does not return to the
                calling process.  'status' is returned to the parent
                process.  (The parent process is usually the operating
                system.)

      Notes:    exit(0) is automatically called when main() exits.

                Typically, the exit status is set to 0 to indicate a
                normal exit, and some other value to indicate an error.
                This is not required, however.

                _exit() has the same function as exit(), but _exit() does
                not flush the stream buffers or execute functions
                registered with onexit() before terminating.

  -------------------------------- Example ---------------------------------

    The following statements set the exit status to 1 if more than one
    command line argument is passed.

            #include <stdio.h>     /* for 'printf' */
            #include <stdlib.h>    /* for 'exit' (also in <process.h>) */

            main(argc, argv)
            int argc;
            char *argv[];
            {
                if (argc > 2) {
                   perror("no more than 1 command line parameter allowed\n");
                   exit(1);
                }
                /* exit here with a status of 0 */
             }

See Also: _exit() abort() exec...() onexit()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson