3 This file is part of Cygwin.
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
16 __SIGFLUSH
= -(_NSIG
+ 1),
17 __SIGSTRACE
= -(_NSIG
+ 2),
18 __SIGCOMMUNE
= -(_NSIG
+ 3),
19 __SIGPENDING
= -(_NSIG
+ 4),
20 __SIGDELETE
= -(_NSIG
+ 5), /* Not currently used */
21 __SIGFLUSHFAST
= -(_NSIG
+ 6),
22 __SIGHOLD
= -(_NSIG
+ 7),
23 __SIGNOHOLD
= -(_NSIG
+ 8),
24 __SIGSETPGRP
= -(_NSIG
+ 9),
25 __SIGTHREADEXIT
= -(_NSIG
+ 10),
26 __SIGPENDINGALL
= -(_NSIG
+ 11),
30 #define SIG_BAD_MASK (1 << (SIGKILL - 1))
34 PROC_ADD_CHILD
= 1, // set up a new child
35 PROC_ATTACH_CHILD
= 2, // attach child or reattach after exec
36 PROC_EXEC_CLEANUP
= 3, // cleanup waiting children after exec
37 PROC_CLEARWAIT
= 4, // clear all waits - signal arrived
38 PROC_WAIT
= 5, // setup for wait() for subproc
39 PROC_EXECING
= 6, // used to get a lock when execing
40 PROC_NOTHING
= 7 // nothing, really
47 class _cygtls
*sigtls
;
53 struct sigpacket
*next
;
56 int setup_handler (void *, struct sigaction
&, _cygtls
*);
59 void sig_dispatch_pending (bool fast
= false);
60 void set_signal_mask (sigset_t
&, sigset_t
);
61 int handle_sigprocmask (int sig
, const sigset_t
*set
,
62 sigset_t
*oldset
, sigset_t
& opmask
);
65 void sig_set_pending (int);
66 int handle_sigsuspend (sigset_t
);
68 int proc_subproc (DWORD
, uintptr_t);
71 void proc_terminate ();
73 bool pid_exists (pid_t
);
74 sigset_t
sig_send (_pinfo
*, siginfo_t
&, class _cygtls
* = NULL
);
75 sigset_t
sig_send (_pinfo
*, int, class _cygtls
* = NULL
);
76 void signal_fixup_after_exec ();
79 int kill_pgrp (pid_t
, siginfo_t
&);
80 void exit_thread (DWORD
) __attribute__ ((noreturn
));
81 void setup_signal_exit (int);
82 int sigwait_common (const sigset_t
*, siginfo_t
*, PLARGE_INTEGER
);
84 class no_thread_exit_protect
89 no_thread_exit_protect (int) {flag
= true; modify
= true;}
90 ~no_thread_exit_protect ()
95 no_thread_exit_protect () {modify
= false;}
96 operator int () {return flag
;}
100 extern "C" void sigdelayed ();
102 extern char myself_nowait_dummy
[];
104 extern struct sigaction
*global_sigs
;
112 worked
= (bool) sig_send (NULL
, __SIGHOLD
) == 0;
114 operator int () const
125 sig_send (NULL
, __SIGNOHOLD
);
133 lock_pthread (): bother (1)
135 pthread::atforkprepare ();
144 pthread::atforkparent ();
148 class hold_everything
151 /* Note the order of the locks below. It is important,
152 to avoid races, that the lock order be preserved.
154 pthread is first because it serves as a master lock
155 against other forks being attempted while this one is active.
157 signals is next to stop signal processing for the duration
160 process is last. If it is put before signals, then a deadlock
161 could be introduced if the process attempts to exit due to a signal. */
162 lock_pthread pthread
;
163 lock_signals signals
;
164 lock_process process
;
167 hold_everything (bool& x
): ischild (x
) {}
168 operator int () const {return signals
;}
174 pthread
.dont_bother ();
175 process
.dont_bother ();
176 signals
.dont_bother ();
182 #define myself_nowait ((_pinfo *) myself_nowait_dummy)