summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2004-05-03 17:21:14 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2004-05-03 17:21:14 +0000
commitcb06773fd66aeb958d8723bdc65b3bc82ea4f1d1 (patch)
tree4dd0c45dcdc596b2898ce1423b07ac2be794af12 /lib
parentcfe49fe7c49490fd81d472fbca32e752e1ea1347 (diff)
Add _Exit(3) as per C99. Discussed with espie@ some time ago.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/Makefile.inc3
-rw-r--r--lib/libc/stdlib/_Exit.c26
-rw-r--r--lib/libc/stdlib/exit.347
3 files changed, 64 insertions, 12 deletions
diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc
index e24eb8d4a5b..80d3c221128 100644
--- a/lib/libc/stdlib/Makefile.inc
+++ b/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 \
setenv.c strtod.c strtol.c strtoll.c strtonum.c strtoul.c strtoull.c \
system.c \
tfind.c tsearch.c _rand48.c drand48.c erand48.c jrand48.c lcong48.c \
- lrand48.c mrand48.c nrand48.c seed48.c srand48.c qabs.c qdiv.c
+ lrand48.c mrand48.c nrand48.c seed48.c srand48.c qabs.c qdiv.c _Exit.c
.if (${MACHINE_ARCH} == "m68k")
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 \
qdiv.3 qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \
strtod.3 strtonum.3 strtol.3 strtoul.3 system.3 tsearch.3
+MLINKS+=exit.3 _Exit.3
MLINKS+=ecvt.3 fcvt.3 ecvt.3 gcvt.3
MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3
MLINKS+=getopt_long.3 getopt_long_only.3
diff --git a/lib/libc/stdlib/_Exit.c b/lib/libc/stdlib/_Exit.c
new file mode 100644
index 00000000000..784015a21d6
--- /dev/null
+++ b/lib/libc/stdlib/_Exit.c
@@ -0,0 +1,26 @@
+/* $OpenBSD: _Exit.c,v 1.1 2004/05/03 17:21:13 millert Exp $ */
+
+/*
+ * Placed in the public domain by Todd C. Miller on January 21, 2004.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$OpenBSD: _Exit.c,v 1.1 2004/05/03 17:21:13 millert Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/*
+ * _Exit() is the ISO/ANSI C99 equivalent of the POSIX _exit() function.
+ * No atexit() handlers are called and no signal handlers are run.
+ * Whether or not stdio buffers are flushed or temporary files are removed
+ * is implementation-dependent. As such it is safest to *not* flush
+ * stdio buffers or remove temporary files. This is also consistent
+ * with most other implementations.
+ */
+void
+_Exit(int status)
+{
+ _exit(status);
+}
diff --git a/lib/libc/stdlib/exit.3 b/lib/libc/stdlib/exit.3
index 8c4b2eed2c2..fa233ac75f1 100644
--- a/lib/libc/stdlib/exit.3
+++ b/lib/libc/stdlib/exit.3
@@ -29,25 +29,30 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: exit.3,v 1.9 2003/06/02 20:18:37 millert Exp $
+.\" $OpenBSD: exit.3,v 1.10 2004/05/03 17:21:13 millert Exp $
.\"
-.Dd June 29, 1991
+.Dd January 21, 2004
.Dt EXIT 3
.Os
.Sh NAME
-.Nm exit
+.Nm exit, _Exit
.Nd perform normal program termination
.Sh SYNOPSIS
.Fd #include <stdlib.h>
.Ft void
.Fn exit "int status"
+.Ft void
+.Fn _Exit "int status"
.Sh DESCRIPTION
The
.Fn exit
-function terminates a process.
+and
+.Fn _Exit
+functions terminate a process.
.Pp
-Before termination it performs the following functions in the
-order listed:
+Before termination,
+.Fn exit
+performs the following operations in the order listed:
.Bl -enum -offset indent
.It
Call the functions registered with the
@@ -63,9 +68,25 @@ Unlink all files created with the
function.
.El
.Pp
-Following this,
+The
+.Fn _Exit
+function terminates without calling the functions registered with the
+.Xr atexit 3
+function.
+The
+.Ox
+implementation of
+.Fn _Exit
+does not flush open output streams or unlink files created with the
+.Xr tmpfile 3
+function.
+However, this behavior is implementation-specific.
+.Pp
+Lastly,
.Fn exit
-calls
+and
+.Fn _Exit
+call
.Xr _exit 2 .
Note that typically
.Xr _exit 2
@@ -75,7 +96,9 @@ on to the parent, thus negative values have less meaning.
.Sh RETURN VALUES
The
.Fn exit
-function never returns.
+and
+.Fn _Exit
+functions never return.
.Sh SEE ALSO
.Xr _exit 2 ,
.Xr atexit 3 ,
@@ -85,5 +108,7 @@ function never returns.
.Sh STANDARDS
The
.Fn exit
-function conforms to
-.St -ansiC .
+and
+.Fn _Exit
+functions conform to
+.St -ansiC-99 .