summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormillert <>2004-05-03 17:21:13 +0000
committermillert <>2004-05-03 17:21:13 +0000
commitec47889776b306f56c691ad8120367908f17299e (patch)
tree9c6d4f28de6cc1195e43c8c46792240d297c5c78
parentc81aca6074576d87ed097daa64164db3977c2b8b (diff)
downloadopenbsd-ec47889776b306f56c691ad8120367908f17299e.tar.gz
openbsd-ec47889776b306f56c691ad8120367908f17299e.tar.bz2
openbsd-ec47889776b306f56c691ad8120367908f17299e.zip
Add _Exit(3) as per C99. Discussed with espie@ some time ago.
-rw-r--r--src/lib/libc/stdlib/Makefile.inc3
-rw-r--r--src/lib/libc/stdlib/_Exit.c26
-rw-r--r--src/lib/libc/stdlib/exit.347
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")
16SRCS+= abs.S div.c labs.c ldiv.c 16SRCS+= 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
48MLINKS+=exit.3 _Exit.3
48MLINKS+=ecvt.3 fcvt.3 ecvt.3 gcvt.3 49MLINKS+=ecvt.3 fcvt.3 ecvt.3 gcvt.3
49MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3 50MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3
50MLINKS+=getopt_long.3 getopt_long_only.3 51MLINKS+=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)
8static 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 */
22void
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
45The 47The
46.Fn exit 48.Fn exit
47function terminates a process. 49and
50.Fn _Exit
51functions terminate a process.
48.Pp 52.Pp
49Before termination it performs the following functions in the 53Before termination,
50order listed: 54.Fn exit
55performs the following operations in the order listed:
51.Bl -enum -offset indent 56.Bl -enum -offset indent
52.It 57.It
53Call the functions registered with the 58Call the functions registered with the
@@ -63,9 +68,25 @@ Unlink all files created with the
63function. 68function.
64.El 69.El
65.Pp 70.Pp
66Following this, 71The
72.Fn _Exit
73function terminates without calling the functions registered with the
74.Xr atexit 3
75function.
76The
77.Ox
78implementation of
79.Fn _Exit
80does not flush open output streams or unlink files created with the
81.Xr tmpfile 3
82function.
83However, this behavior is implementation-specific.
84.Pp
85Lastly,
67.Fn exit 86.Fn exit
68calls 87and
88.Fn _Exit
89call
69.Xr _exit 2 . 90.Xr _exit 2 .
70Note that typically 91Note 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
76The 97The
77.Fn exit 98.Fn exit
78function never returns. 99and
100.Fn _Exit
101functions 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
86The 109The
87.Fn exit 110.Fn exit
88function conforms to 111and
89.St -ansiC . 112.Fn _Exit
113functions conform to
114.St -ansiC-99 .