summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/sigproc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/sigproc.cc')
-rw-r--r--winsup/cygwin/sigproc.cc37
1 files changed, 17 insertions, 20 deletions
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 6471665bf..dff2c1bd4 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -114,9 +114,6 @@ HANDLE NO_COPY signal_arrived; // Event signaled when a signal has
Static DWORD proc_loop_wait = 1000; // Wait for subprocesses to exit
-Static HANDLE sigcomplete_main; // Event signaled when a signal has
- // finished processing for the main
- // thread
HANDLE NO_COPY sigCONT; // Used to "STOP" a process
Static cygthread *hwait_sig; // Handle of wait_sig thread
Static cygthread *hwait_subproc; // Handle of sig_subproc thread
@@ -646,7 +643,6 @@ sigproc_terminate (void)
{
sigproc_printf ("entering");
// finished with anything it is doing
- ForceCloseHandle (sigcomplete_main);
if (!hExeced)
{
HANDLE sendsig = myself->sendsig;
@@ -681,8 +677,8 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
HANDLE sendsig;
sigpacket pack;
+ pack.wakeup = NULL;
bool wait_for_completion;
- // FIXMENOW: Avoid using main thread's completion event!
if (!(its_me = (p == NULL || p == myself || p == myself_nowait)))
wait_for_completion = false;
else
@@ -710,11 +706,7 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
}
if (its_me)
- {
- sendsig = myself->sendsig;
- if (wait_for_completion)
- pack.wakeup = sigcomplete_main;
- }
+ sendsig = myself->sendsig;
else
{
HANDLE hp = OpenProcess (PROCESS_DUP_HANDLE, false, p->dwProcessId);
@@ -756,7 +748,13 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
pack.si.si_uid = myself->uid;
pack.pid = myself->pid;
pack.tls = (_threadinfo *) tls;
- pack.mask_storage = 0;
+ if (wait_for_completion)
+ {
+ pack.wakeup = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
+ sigproc_printf ("wakeup %p", pack.wakeup);
+ ProtectHandle (pack.wakeup);
+ }
+
DWORD nb;
if (!WriteFile (sendsig, &pack, sizeof (pack), &nb, NULL) || nb != sizeof (pack))
{
@@ -815,6 +813,9 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
call_signal_handler_now ();
out:
+ if (pack.wakeup)
+ ForceCloseHandle (pack.wakeup);
+
if (si.si_signo != __SIGPENDING)
/* nothing */;
else if (!rc)
@@ -1028,8 +1029,7 @@ pending_signals::add (sigpacket& pack)
empty = 0;
se = sigs + empty;
*se = pack;
- se->mask_storage = *(pack.mask);
- se->mask = &se->mask_storage;
+ se->mask = &myself->getsigmask ();
se->next = NULL;
if (end)
end->next = se;
@@ -1077,12 +1077,8 @@ wait_sig (VOID *self)
/* Initialization */
(void) SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY);
- /* sigcomplete_main - event used to signal main thread on signal
- completion */
if (!CreatePipe (&readsig, &myself->sendsig, sec_user_nih (sa_buf), 0))
api_fatal ("couldn't create signal pipe, %E");
- sigcomplete_main = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
- sigproc_printf ("sigcomplete_main %p", sigcomplete_main);
sigCONT = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
/* Setting dwProcessId flags that this process is now capable of receiving
@@ -1093,8 +1089,6 @@ wait_sig (VOID *self)
myself->process_state |= PID_ACTIVE;
myself->process_state &= ~PID_INITIALIZING;
- ProtectHandle (sigcomplete_main);
-
/* If we've been execed, then there is still a stub left in the previous
windows process waiting to see if it's started a cygwin process or not.
Signalling subproc_ready indicates that we are a cygwin process. */
@@ -1193,7 +1187,10 @@ wait_sig (VOID *self)
break;
}
if (pack.wakeup)
- SetEvent (pack.wakeup);
+ {
+ SetEvent (pack.wakeup);
+ sigproc_printf ("signalled %p", pack.wakeup);
+ }
}
sigproc_printf ("done");