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