1*46050Sbostic /*- 2*46050Sbostic * Copyright (c) 1990 The Regents of the University of California. 3*46050Sbostic * All rights reserved. 4*46050Sbostic * 5*46050Sbostic * %sccs.include.redist.c% 6*46050Sbostic */ 7*46050Sbostic 826641Sdonn #if defined(LIBC_SCCS) && !defined(lint) 9*46050Sbostic static char sccsid[] = "@(#)exit.c 5.3 (Berkeley) 01/20/91"; 10*46050Sbostic #endif /* LIBC_SCCS and not lint */ 1113264Sroot 12*46050Sbostic #include "atexit.h" 13*46050Sbostic 14*46050Sbostic void (*__cleanup)(); 15*46050Sbostic 16*46050Sbostic /* 17*46050Sbostic * Exit, flushing stdio buffers if necessary. 18*46050Sbostic */ 19*46050Sbostic exit(status) 20*46050Sbostic int status; 2113264Sroot { 22*46050Sbostic register struct atexit *p; 23*46050Sbostic register int n; 2413264Sroot 25*46050Sbostic for (p = __atexit; p; p = p->next) 26*46050Sbostic for (n = p->ind; --n >= 0;) 27*46050Sbostic (*p->fns[n])(); 28*46050Sbostic if (__cleanup) 29*46050Sbostic (*__cleanup)(); 30*46050Sbostic _exit(status); 3113264Sroot } 32