Browse Source

Add _Exit(3) as per C99. Discussed with espie@ some time ago.

OPENBSD_3_6
millert 20 years ago
parent
commit
d3af4c4238
4 changed files with 66 additions and 13 deletions
  1. +2
    -1
      src/include/stdlib.h
  2. +2
    -1
      src/lib/libc/stdlib/Makefile.inc
  3. +26
    -0
      src/lib/libc/stdlib/_Exit.c
  4. +36
    -11
      src/lib/libc/stdlib/exit.3

+ 2
- 1
src/include/stdlib.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: stdlib.h,v 1.29 2004/01/21 19:50:39 millert Exp $ */
/* $OpenBSD: stdlib.h,v 1.30 2004/05/03 17:21:13 millert Exp $ */
/* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */
/*-
@ -111,6 +111,7 @@ void *calloc(size_t, size_t);
div_t div(int, int);
char *ecvt(double, int, int *, int *);
__dead void exit(int);
__dead void _Exit(int);
char *fcvt(double, int, int *, int *);
void free(void *);
char *gcvt(double, int, char *);


+ 2
- 1
src/lib/libc/stdlib/Makefile.inc View File

@ -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


+ 26
- 0
src/lib/libc/stdlib/_Exit.c View File

@ -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);
}

+ 36
- 11
src/lib/libc/stdlib/exit.3 View File

@ -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 .

Loading…
Cancel
Save