sl@0
|
1 |
/* EXIT.C
|
sl@0
|
2 |
*
|
sl@0
|
3 |
* Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
4 |
* All rights reserved.
|
sl@0
|
5 |
*/
|
sl@0
|
6 |
|
sl@0
|
7 |
/*
|
sl@0
|
8 |
* Copyright (c) 1990 Regents of the University of California.
|
sl@0
|
9 |
* All rights reserved.
|
sl@0
|
10 |
*
|
sl@0
|
11 |
* %sccs.include.redist.c%
|
sl@0
|
12 |
*/
|
sl@0
|
13 |
|
sl@0
|
14 |
/*
|
sl@0
|
15 |
FUNCTION
|
sl@0
|
16 |
<<exit>>---end program execution
|
sl@0
|
17 |
|
sl@0
|
18 |
INDEX
|
sl@0
|
19 |
exit
|
sl@0
|
20 |
|
sl@0
|
21 |
ANSI_SYNOPSIS
|
sl@0
|
22 |
#include <stdlib.h>
|
sl@0
|
23 |
void exit(int <[code]>);
|
sl@0
|
24 |
|
sl@0
|
25 |
TRAD_SYNOPSIS
|
sl@0
|
26 |
#include <stdlib.h>
|
sl@0
|
27 |
void exit(<[code]>)
|
sl@0
|
28 |
int <[code]>;
|
sl@0
|
29 |
|
sl@0
|
30 |
DESCRIPTION
|
sl@0
|
31 |
Use <<exit>> to return control from a program to the host operating
|
sl@0
|
32 |
environment. Use the argument <[code]> to pass an exit status to the
|
sl@0
|
33 |
operating environment: two particular values, <<EXIT_SUCCESS>> and
|
sl@0
|
34 |
<<EXIT_FAILURE>>, are defined in `<<stdlib.h>>' to indicate success or
|
sl@0
|
35 |
failure in a portable fashion.
|
sl@0
|
36 |
|
sl@0
|
37 |
<<exit>> does two kinds of cleanup before ending execution of your
|
sl@0
|
38 |
program. First, it calls all application-defined cleanup functions
|
sl@0
|
39 |
you have enrolled with <<atexit>>. Second, files and streams are
|
sl@0
|
40 |
cleaned up: any pending output is delivered to the host system, each
|
sl@0
|
41 |
open file or stream is closed, and files created by <<tmpfile>> are
|
sl@0
|
42 |
deleted.
|
sl@0
|
43 |
|
sl@0
|
44 |
RETURNS
|
sl@0
|
45 |
<<exit>> does not return to its caller.
|
sl@0
|
46 |
|
sl@0
|
47 |
PORTABILITY
|
sl@0
|
48 |
ANSI C requires <<exit>>, and specifies that <<EXIT_SUCCESS>> and
|
sl@0
|
49 |
<<EXIT_FAILURE>> must be defined.
|
sl@0
|
50 |
|
sl@0
|
51 |
Supporting OS subroutines required: <<_exit>>.
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
|
sl@0
|
54 |
#include <stdlib.h>
|
sl@0
|
55 |
#include <unistd.h> /* for _exit() declaration */
|
sl@0
|
56 |
#include <reent.h>
|
sl@0
|
57 |
#include <stdlib_r.h> /* for _atexit_processing() */
|
sl@0
|
58 |
|
sl@0
|
59 |
#ifndef _REENT_ONLY
|
sl@0
|
60 |
|
sl@0
|
61 |
/* GCC knows that exit() should not return, but prior to GCC 2.5 there is
|
sl@0
|
62 |
* no way of declaring the function as __attribute__ ((noreturn)).
|
sl@0
|
63 |
* Expect to be warned about this function in MARM builds.
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
EXPORT_C void
|
sl@0
|
66 |
exit (int code) _ATTRIBUTE((noreturn))
|
sl@0
|
67 |
{
|
sl@0
|
68 |
_atexit_processing_r(_REENT);
|
sl@0
|
69 |
_exit (code);
|
sl@0
|
70 |
|
sl@0
|
71 |
/* GCC may insert a call to abort() here. */
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
#endif
|