Add reminder to investigate recursive commands for 2.6
[fvwm.git] / libs / fvwmsignal.h
blob85dfabe5117be91963b008b44eabfd894c6c9855
1 /* -*-c-*- */
2 #ifndef FVWMSIGNAL_H
3 #define FVWMSIGNAL_H
5 /* This module provides wrappers around system functions that could
6 * potentially block, e.g. select(). These wrappers will check that
7 * the "terminate" flag is still clear and then call the system
8 * function in one atomic operation. This ensures that fvwm will not
9 * block in a system function once it has received the signal to quit.
11 * This module was written by Chris Rankin, rankinc@zipworld.com.au
13 /* This module is intended to use POSIX.1 signal semantics, since most
14 * modern systems can reasonably be expected to support POSIX and since
15 * the semantics of the old "signal()" function vary from system to system.
16 * If POSIX.1 is not available then the module can provide BSD signal
17 * semantics, which can be summarised as follows:
18 * - the signal handler will NOT uninstall itself once it has been called
19 * - a signal will be temporarily blocked from further delivery so long
20 * as its handler is running
21 * - certain system calls will be automatically restarted if interrupted
22 * by a signal
25 #if !defined(HAVE_SIGACTION) \
26 && defined(HAVE_SIGBLOCK) && defined(HAVE_SIGSETMASK)
27 # define USE_BSD_SIGNALS
28 #endif
30 #ifdef USE_BSD_SIGNALS
31 # define BSD_BLOCK_SIGNALS int old_mask = sigblock( fvwmGetSignalMask() )
32 # define BSB_BLOCK_ALL_SIGNALS int old_mask = sigblock( ~0 )
33 # define BSD_UNBLOCK_SIGNALS sigsetmask( old_mask )
34 #else
35 # define BSD_BLOCK_SIGNALS
36 # define BSD_BLOCK_ALL_SIGNALS
37 # define BSD_UNBLOCK_SIGNALS
38 #endif
40 #include <signal.h>
41 #include "ftime.h"
42 #if HAVE_SYS_SELECT_H
43 # include <sys/select.h>
44 #endif
47 * Global variables
49 extern volatile sig_atomic_t isTerminated;
53 * Module prototypes
55 RETSIGTYPE fvwmReapChildren(int sig);
56 extern void fvwmSetTerminate(int sig);
58 #ifdef USE_BSD_SIGNALS
59 extern void fvwmSetSignalMask(int);
60 extern int fvwmGetSignalMask(void);
61 #endif
63 #ifdef HAVE_SELECT
64 extern int fvwmSelect(
65 fd_set_size_t nfds, fd_set *readfds, fd_set *writefds,
66 fd_set *exceptfds, struct timeval *timeout);
67 #endif
69 #endif /* FVWMSIGNAL_H */