diff options
author | millert <> | 2004-05-03 17:21:13 +0000 |
---|---|---|
committer | millert <> | 2004-05-03 17:21:13 +0000 |
commit | ec47889776b306f56c691ad8120367908f17299e (patch) | |
tree | 9c6d4f28de6cc1195e43c8c46792240d297c5c78 /src | |
parent | c81aca6074576d87ed097daa64164db3977c2b8b (diff) | |
download | openbsd-ec47889776b306f56c691ad8120367908f17299e.tar.gz openbsd-ec47889776b306f56c691ad8120367908f17299e.tar.bz2 openbsd-ec47889776b306f56c691ad8120367908f17299e.zip |
Add _Exit(3) as per C99. Discussed with espie@ some time ago.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/stdlib/Makefile.inc | 3 | ||||
-rw-r--r-- | src/lib/libc/stdlib/_Exit.c | 26 | ||||
-rw-r--r-- | src/lib/libc/stdlib/exit.3 | 47 |
3 files changed, 64 insertions, 12 deletions
diff --git a/src/lib/libc/stdlib/Makefile.inc b/src/lib/libc/stdlib/Makefile.inc index e24eb8d4a5..80d3c22112 100644 --- a/src/lib/libc/stdlib/Makefile.inc +++ b/src/lib/libc/stdlib/Makefile.inc | |||
@@ -10,7 +10,7 @@ SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c atoll.c bsearch.c \ | |||
10 | setenv.c strtod.c strtol.c strtoll.c strtonum.c strtoul.c strtoull.c \ | 10 | setenv.c strtod.c strtol.c strtoll.c strtonum.c strtoul.c strtoull.c \ |
11 | system.c \ | 11 | system.c \ |
12 | tfind.c tsearch.c _rand48.c drand48.c erand48.c jrand48.c lcong48.c \ | 12 | tfind.c tsearch.c _rand48.c drand48.c erand48.c jrand48.c lcong48.c \ |
13 | lrand48.c mrand48.c nrand48.c seed48.c srand48.c qabs.c qdiv.c | 13 | lrand48.c mrand48.c nrand48.c seed48.c srand48.c qabs.c qdiv.c _Exit.c |
14 | 14 | ||
15 | .if (${MACHINE_ARCH} == "m68k") | 15 | .if (${MACHINE_ARCH} == "m68k") |
16 | SRCS+= abs.S div.c labs.c ldiv.c | 16 | SRCS+= abs.S div.c labs.c ldiv.c |
@@ -45,6 +45,7 @@ MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \ | |||
45 | qdiv.3 qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \ | 45 | qdiv.3 qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \ |
46 | strtod.3 strtonum.3 strtol.3 strtoul.3 system.3 tsearch.3 | 46 | strtod.3 strtonum.3 strtol.3 strtoul.3 system.3 tsearch.3 |
47 | 47 | ||
48 | MLINKS+=exit.3 _Exit.3 | ||
48 | MLINKS+=ecvt.3 fcvt.3 ecvt.3 gcvt.3 | 49 | MLINKS+=ecvt.3 fcvt.3 ecvt.3 gcvt.3 |
49 | MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3 | 50 | MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3 |
50 | MLINKS+=getopt_long.3 getopt_long_only.3 | 51 | MLINKS+=getopt_long.3 getopt_long_only.3 |
diff --git a/src/lib/libc/stdlib/_Exit.c b/src/lib/libc/stdlib/_Exit.c new file mode 100644 index 0000000000..784015a21d --- /dev/null +++ b/src/lib/libc/stdlib/_Exit.c | |||
@@ -0,0 +1,26 @@ | |||
1 | /* $OpenBSD: _Exit.c,v 1.1 2004/05/03 17:21:13 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Placed in the public domain by Todd C. Miller on January 21, 2004. | ||
5 | */ | ||
6 | |||
7 | #if defined(LIBC_SCCS) && !defined(lint) | ||
8 | static char *rcsid = "$OpenBSD: _Exit.c,v 1.1 2004/05/03 17:21:13 millert Exp $"; | ||
9 | #endif /* LIBC_SCCS and not lint */ | ||
10 | |||
11 | #include <stdlib.h> | ||
12 | #include <unistd.h> | ||
13 | |||
14 | /* | ||
15 | * _Exit() is the ISO/ANSI C99 equivalent of the POSIX _exit() function. | ||
16 | * No atexit() handlers are called and no signal handlers are run. | ||
17 | * Whether or not stdio buffers are flushed or temporary files are removed | ||
18 | * is implementation-dependent. As such it is safest to *not* flush | ||
19 | * stdio buffers or remove temporary files. This is also consistent | ||
20 | * with most other implementations. | ||
21 | */ | ||
22 | void | ||
23 | _Exit(int status) | ||
24 | { | ||
25 | _exit(status); | ||
26 | } | ||
diff --git a/src/lib/libc/stdlib/exit.3 b/src/lib/libc/stdlib/exit.3 index 8c4b2eed2c..fa233ac75f 100644 --- a/src/lib/libc/stdlib/exit.3 +++ b/src/lib/libc/stdlib/exit.3 | |||
@@ -29,25 +29,30 @@ | |||
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
30 | .\" SUCH DAMAGE. | 30 | .\" SUCH DAMAGE. |
31 | .\" | 31 | .\" |
32 | .\" $OpenBSD: exit.3,v 1.9 2003/06/02 20:18:37 millert Exp $ | 32 | .\" $OpenBSD: exit.3,v 1.10 2004/05/03 17:21:13 millert Exp $ |
33 | .\" | 33 | .\" |
34 | .Dd June 29, 1991 | 34 | .Dd January 21, 2004 |
35 | .Dt EXIT 3 | 35 | .Dt EXIT 3 |
36 | .Os | 36 | .Os |
37 | .Sh NAME | 37 | .Sh NAME |
38 | .Nm exit | 38 | .Nm exit, _Exit |
39 | .Nd perform normal program termination | 39 | .Nd perform normal program termination |
40 | .Sh SYNOPSIS | 40 | .Sh SYNOPSIS |
41 | .Fd #include <stdlib.h> | 41 | .Fd #include <stdlib.h> |
42 | .Ft void | 42 | .Ft void |
43 | .Fn exit "int status" | 43 | .Fn exit "int status" |
44 | .Ft void | ||
45 | .Fn _Exit "int status" | ||
44 | .Sh DESCRIPTION | 46 | .Sh DESCRIPTION |
45 | The | 47 | The |
46 | .Fn exit | 48 | .Fn exit |
47 | function terminates a process. | 49 | and |
50 | .Fn _Exit | ||
51 | functions terminate a process. | ||
48 | .Pp | 52 | .Pp |
49 | Before termination it performs the following functions in the | 53 | Before termination, |
50 | order listed: | 54 | .Fn exit |
55 | performs the following operations in the order listed: | ||
51 | .Bl -enum -offset indent | 56 | .Bl -enum -offset indent |
52 | .It | 57 | .It |
53 | Call the functions registered with the | 58 | Call the functions registered with the |
@@ -63,9 +68,25 @@ Unlink all files created with the | |||
63 | function. | 68 | function. |
64 | .El | 69 | .El |
65 | .Pp | 70 | .Pp |
66 | Following this, | 71 | The |
72 | .Fn _Exit | ||
73 | function terminates without calling the functions registered with the | ||
74 | .Xr atexit 3 | ||
75 | function. | ||
76 | The | ||
77 | .Ox | ||
78 | implementation of | ||
79 | .Fn _Exit | ||
80 | does not flush open output streams or unlink files created with the | ||
81 | .Xr tmpfile 3 | ||
82 | function. | ||
83 | However, this behavior is implementation-specific. | ||
84 | .Pp | ||
85 | Lastly, | ||
67 | .Fn exit | 86 | .Fn exit |
68 | calls | 87 | and |
88 | .Fn _Exit | ||
89 | call | ||
69 | .Xr _exit 2 . | 90 | .Xr _exit 2 . |
70 | Note that typically | 91 | Note that typically |
71 | .Xr _exit 2 | 92 | .Xr _exit 2 |
@@ -75,7 +96,9 @@ on to the parent, thus negative values have less meaning. | |||
75 | .Sh RETURN VALUES | 96 | .Sh RETURN VALUES |
76 | The | 97 | The |
77 | .Fn exit | 98 | .Fn exit |
78 | function never returns. | 99 | and |
100 | .Fn _Exit | ||
101 | functions never return. | ||
79 | .Sh SEE ALSO | 102 | .Sh SEE ALSO |
80 | .Xr _exit 2 , | 103 | .Xr _exit 2 , |
81 | .Xr atexit 3 , | 104 | .Xr atexit 3 , |
@@ -85,5 +108,7 @@ function never returns. | |||
85 | .Sh STANDARDS | 108 | .Sh STANDARDS |
86 | The | 109 | The |
87 | .Fn exit | 110 | .Fn exit |
88 | function conforms to | 111 | and |
89 | .St -ansiC . | 112 | .Fn _Exit |
113 | functions conform to | ||
114 | .St -ansiC-99 . | ||