1
/* ==== _exit.c ============================================================
2
* Copyright (c) 1994 by Chris Provenzano, proven@mit.edu
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. All advertising materials mentioning features or use of this software
14
* must display the following acknowledgement:
15
* This product includes software developed by Chris Provenzano.
16
* 4. The name of Chris Provenzano may not be used to endorse or promote
17
* products derived from this software without specific prior written
20
* THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
21
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
* ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY
24
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32
* Description : The locking functions for stdio.
34
* 1.00 94/09/04 proven
35
* -Started coding this file.
39
static const char rcsid[] = "$Id$";
45
/* ==========================================================================
48
* Change all file descriptors back to their original state,
49
* before exiting for good.
51
void _exit(int status)
55
pthread_sched_prevent();
57
for (fd = 0; fd < dtablesize; fd++) {
58
if (fd_table[fd] == NULL) {
61
/* Is it a kernel fd ? */
62
if ((!fd_table[fd]->ops) || (fd_table[fd]->ops->use_kfds != 1)) {
65
switch (fd_table[fd]->type) {
67
machdep_sys_fcntl(fd_table[fd]->fd.i, F_SETFL, fd_table[fd]->flags);
68
fd_table[fd]->type = FD_TEST_HALF_DUPLEX;
71
machdep_sys_fcntl(fd_table[fd]->fd.i, F_SETFL, fd_table[fd]->flags);
72
fd_table[fd]->type = FD_TEST_FULL_DUPLEX;
78
machdep_sys_exit(status);