Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / xcvs / dist / src / exithandle.c
blobecb85db2b8ba3618bd43159b3e1f7b5f6706544f
1 /*
2 * Copyright (c) 2003, Derek Price and Ximbiot <http://ximbiot.com>
4 * You may distribute under the terms of the GNU General Public License
5 * as specified in the README file that comes with the CVS source
6 * distribution.
8 * This is a convenience wrapper for some of the functions in lib/sighandle.c.
9 */
11 #include "cvs.h"
14 * Register a handler for all signals.
16 void
17 signals_register (RETSIGTYPE (*handler)(int))
19 #ifndef DONT_USE_SIGNALS
20 #ifdef SIGABRT
21 (void) SIG_register (SIGABRT, handler);
22 #endif
23 #ifdef SIGHUP
24 (void) SIG_register (SIGHUP, handler);
25 #endif
26 #ifdef SIGINT
27 (void) SIG_register (SIGINT, handler);
28 #endif
29 #ifdef SIGQUIT
30 (void) SIG_register (SIGQUIT, handler);
31 #endif
32 #ifdef SIGPIPE
33 (void) SIG_register (SIGPIPE, handler);
34 #endif
35 #ifdef SIGTERM
36 (void) SIG_register (SIGTERM, handler);
37 #endif
38 #endif /* !DONT_USE_SIGNALS */
44 * Register a handler for all signals and exit.
46 void
47 cleanup_register (void (*handler) (void))
49 atexit (handler);
51 /* Always calling this function before any other exit handlers guarantees
52 * that signals will be blocked by the time the other exit handlers are
53 * called.
55 * SIG_beginCrSect will be called once for each handler registered via
56 * cleanup_register, but there is no unregister routine for atexit() and
57 * this seems like minimal overhead.
59 * There is no reason to unblock signals again when the exit handlers are
60 * done since the program will be exiting anyhow.
62 atexit (SIG_beginCrSect);