macro and text revision (-mdoc version 3)
[unix-history] / usr / src / lib / libc / stdlib / exit.c
CommitLineData
86338cde
KB
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
2ce81398 8#if defined(LIBC_SCCS) && !defined(lint)
f0a345ab 9static char sccsid[] = "@(#)exit.c 5.4 (Berkeley) %G%";
86338cde
KB
10#endif /* LIBC_SCCS and not lint */
11
f0a345ab
DS
12#include <stdlib.h>
13#include <unistd.h>
86338cde
KB
14#include "atexit.h"
15
16void (*__cleanup)();
538e8d05 17
86338cde
KB
18/*
19 * Exit, flushing stdio buffers if necessary.
20 */
f0a345ab 21void
86338cde
KB
22exit(status)
23 int status;
538e8d05 24{
86338cde
KB
25 register struct atexit *p;
26 register int n;
538e8d05 27
86338cde
KB
28 for (p = __atexit; p; p = p->next)
29 for (n = p->ind; --n >= 0;)
30 (*p->fns[n])();
31 if (__cleanup)
32 (*__cleanup)();
33 _exit(status);
538e8d05 34}