File: fvwmsignal.h

package info (click to toggle)
fvwm 1:2.6.8-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 15,804 kB
  • sloc: ansic: 145,770; xml: 17,093; perl: 7,302; sh: 4,921; makefile: 1,094; yacc: 688; lex: 187; sed: 11
file content (70 lines) | stat: -rw-r--r-- 2,094 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* -*-c-*- */
#ifndef FVWMSIGNAL_H
#define FVWMSIGNAL_H

/* This module provides wrappers around system functions that could
 * potentially block, e.g. select(). These wrappers will check that
 * the "terminate" flag is still clear and then call the system
 * function in one atomic operation. This ensures that fvwm will not
 * block in a system function once it has received the signal to quit.
 *
 * This module was written by Chris Rankin,  rankinc@zipworld.com.au
 */
/* This module is intended to use POSIX.1 signal semantics, since most
 * modern systems can reasonably be expected to support POSIX and since
 * the semantics of the old "signal()" function vary from system to system.
 * If POSIX.1 is not available then the module can provide BSD signal
 * semantics, which can be summarised as follows:
 *  - the signal handler will NOT uninstall itself once it has been called
 *  - a signal will be temporarily blocked from further delivery so long
 *    as its handler is running
 *  - certain system calls will be automatically restarted if interrupted
 *    by a signal
 */

#if !defined(HAVE_SIGACTION) \
    && defined(HAVE_SIGBLOCK) && defined(HAVE_SIGSETMASK)
#  define USE_BSD_SIGNALS
#endif

#ifdef USE_BSD_SIGNALS
#  define BSD_BLOCK_SIGNALS      int old_mask = sigblock( fvwmGetSignalMask() )
#  define BSB_BLOCK_ALL_SIGNALS  int old_mask = sigblock( ~0 )
#  define BSD_UNBLOCK_SIGNALS    sigsetmask( old_mask )
#else
#  define BSD_BLOCK_SIGNALS
#  define BSD_BLOCK_ALL_SIGNALS
#  define BSD_UNBLOCK_SIGNALS
#endif

#include <signal.h>
#include "ftime.h"
#if HAVE_SYS_SELECT_H
#  include <sys/select.h>
#endif

/*
 * Global variables
 */
extern volatile sig_atomic_t isTerminated;


/*
 * Module prototypes
 */
RETSIGTYPE fvwmReapChildren(int sig);
extern void fvwmSetTerminate(int sig);

#ifdef USE_BSD_SIGNALS
extern void fvwmSetSignalMask(int);
extern int fvwmGetSignalMask(void);
#endif

#ifdef  HAVE_SELECT
extern int fvwmSelect(
	fd_set_size_t nfds, fd_set *readfds, fd_set *writefds,
	fd_set *exceptfds, struct timeval *timeout);
#endif

#endif /* FVWMSIGNAL_H */