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),
27 __SIGNONCYGCHLD
= -(_NSIG
+ 12),
31 #define SIG_BAD_MASK (1 << (SIGKILL - 1))
35 PROC_ADD_CHILD
= 1, // set up a new child
36 PROC_ATTACH_CHILD
= 2, // attach child or reattach after exec
37 PROC_EXEC_CLEANUP
= 3, // cleanup waiting children after exec
38 PROC_CLEARWAIT
= 4, // clear all waits - signal arrived
39 PROC_WAIT
= 5, // setup for wait() for subproc
40 PROC_EXECING
= 6, // used to get a lock when execing
41 PROC_NOTHING
= 7 // nothing, really
48 class _cygtls
*sigtls
;
54 struct sigpacket
*next
;
57 int setup_handler (void *, struct sigaction
&, _cygtls
*);
60 void sig_dispatch_pending (bool fast
= false);
61 void set_signal_mask (sigset_t
&, sigset_t
);
62 int handle_sigprocmask (int sig
, const sigset_t
*set
,
63 sigset_t
*oldset
, sigset_t
& opmask
);
66 void sig_set_pending (int);
67 int handle_sigsuspend (sigset_t
);
69 int proc_subproc (DWORD
, uintptr_t);
72 void proc_terminate ();
74 bool pid_exists (pid_t
);
75 sigset_t
sig_send (_pinfo
*, siginfo_t
&, class _cygtls
* = NULL
);
76 sigset_t
sig_send (_pinfo
*, int, class _cygtls
* = NULL
);
77 void signal_fixup_after_exec ();
80 int kill_pgrp (pid_t
, siginfo_t
&);
81 void exit_thread (DWORD
) __attribute__ ((noreturn
));
82 void setup_signal_exit (int);
83 int sigwait_common (const sigset_t
*, siginfo_t
*, PLARGE_INTEGER
);
85 class no_thread_exit_protect
90 no_thread_exit_protect (int) {flag
= true; modify
= true;}
91 ~no_thread_exit_protect ()
96 no_thread_exit_protect () {modify
= false;}
97 operator int () {return flag
;}
101 extern "C" void sigdelayed ();
103 extern char myself_nowait_dummy
[];
105 extern struct sigaction
*global_sigs
;
113 worked
= (bool) sig_send (NULL
, __SIGHOLD
) == 0;
115 operator int () const
126 sig_send (NULL
, __SIGNOHOLD
);
134 lock_pthread (): bother (1)
136 pthread::atforkprepare ();
145 pthread::atforkparent ();
149 class hold_everything
152 /* Note the order of the locks below. It is important,
153 to avoid races, that the lock order be preserved.
155 pthread is first because it serves as a master lock
156 against other forks being attempted while this one is active.
158 signals is next to stop signal processing for the duration
161 process is last. If it is put before signals, then a deadlock
162 could be introduced if the process attempts to exit due to a signal. */
163 lock_pthread pthread
;
164 lock_signals signals
;
165 lock_process process
;
168 hold_everything (bool& x
): ischild (x
) {}
169 operator int () const {return signals
;}
175 pthread
.dont_bother ();
176 process
.dont_bother ();
177 signals
.dont_bother ();
183 #define myself_nowait ((_pinfo *) myself_nowait_dummy)