From fdcae03c0fc805f74b0060ae398ff561742a982b Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 17 Apr 2011 21:45:28 +0000 Subject: [PATCH] * signal.cc (_pinfo::kill): Return 0 when attempting to test for existence of an existed process which has not yet been reaped. --- winsup/cygwin/ChangeLog | 5 ++++ winsup/cygwin/signal.cc | 52 ++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c07063386..3530834cf 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2011-04-17 Christopher Faylor + + * signal.cc (_pinfo::kill): Return 0 when attempting to test for + existence of an existed process which has not yet been reaped. + 2011-04-17 Christopher Faylor * cygheap.h (init_cygheap::ctty): Use base class so that console can diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 615104e80..41eb03ec5 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -221,35 +221,43 @@ handle_sigprocmask (int how, const sigset_t *set, sigset_t *oldset, sigset_t& op int __stdcall _pinfo::kill (siginfo_t& si) { + int res; + DWORD this_process_state; + sig_dispatch_pending (); - int res = 0; - bool sendSIGCONT; + if (exists ()) + { + bool sendSIGCONT; + if ((sendSIGCONT = (si.si_signo < 0))) + si.si_signo = -si.si_signo; - if (!exists ()) + if (si.si_signo == 0) + res = 0; + else if ((res = sig_send (this, si))) + { + sigproc_printf ("%d = sig_send, %E ", res); + res = -1; + } + else if (sendSIGCONT) + { + siginfo_t si2 = {0}; + si2.si_signo = SIGCONT; + si2.si_code = SI_KERNEL; + sig_send (this, si2); + } + } + else if (si.si_signo == 0 && this) + { + this_process_state = process_state; + res = 0; + } + else { set_errno (ESRCH); - return -1; - } - - if ((sendSIGCONT = (si.si_signo < 0))) - si.si_signo = -si.si_signo; - - DWORD this_process_state = process_state; - if (si.si_signo == 0) - /* ok */; - else if ((res = sig_send (this, si))) - { - sigproc_printf ("%d = sig_send, %E ", res); + this_process_state = 0; res = -1; } - else if (sendSIGCONT) - { - siginfo_t si2 = {0}; - si2.si_signo = SIGCONT; - si2.si_code = SI_KERNEL; - sig_send (this, si2); - } syscall_printf ("%d = _pinfo::kill (%d, %d), process_state %p", res, pid, si.si_signo, this_process_state);