]> pd.if.org Git - pdclib/blob - functions/stdlib/exit.c
5cb2a508fe19838baa4e9e95f08707af90e671c4
[pdclib] / functions / stdlib / exit.c
1 /* $Id$ */
2
3 /* Release $Name$ */
4
5 /* exit( int )
6
7    This file is part of the Public Domain C Library (PDCLib).
8    Permission is granted to use, modify, and / or redistribute at will.
9 */
10
11 #include <stdlib.h>
12
13 #ifndef REGTEST
14
15 struct _PDCLIB_exitfunc_t * regstack = NULL;
16
17 void exit( int status )
18 {
19     struct _PDCLIB_exitfunc_t * next = regstack;
20     while ( next != NULL )
21     {
22         next->func();
23         regstack = next->next;
24         free( next );
25         next = regstack;
26     }
27     /* TODO: Flush and close open streams. Remove tmpfile() files. */
28     _Exit( status );
29 }
30
31 #endif
32
33 #ifdef TEST
34 #include <_PDCLIB_test.h>
35
36 int main()
37 {
38     BEGIN_TESTS;
39     TESTCASE( NO_TESTDRIVER );
40     return TEST_RESULTS;
41 }
42
43 #endif