diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4a87af0e9..d861cf088 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2003-11-23 Christopher Faylor + + * sigproc.cc (proc_exists): A zombie process does not exist. + (sig_send): Improve debugging output. Wait for pipe to be created + before trying to send to it. Call call_signal_handler_now if sending a + signal to myself. + 2003-11-22 Christopher Faylor * dcrt0.cc (check_sanity_and_sync): Correct api major version check so diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 680b12dc0..0578cad8c 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -1,8 +1,8 @@ /* sigproc.cc: inter/intra signal and sub process handler - Copyright 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. + Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. - Written by Christopher Faylor + Written by Christopher Faylor This file is part of Cygwin. @@ -44,7 +44,7 @@ details. */ #define wake_wait_subproc() SetEvent (events[0]) -#define no_signals_available() (!hwait_sig || !sig_loop_wait) +#define no_signals_available() (!hwait_sig || !sig_loop_wait && !exit_state) #define NZOMBIES 256 @@ -267,7 +267,7 @@ pid_exists (pid_t pid) BOOL __stdcall proc_exists (_pinfo *p) { - return p && !(p->process_state & PID_EXITED); + return p && !(p->process_state & (PID_EXITED | PID_ZOMBIE)); } /* Return 1 if this is one of our children, zero otherwise. @@ -428,9 +428,8 @@ proc_subproc (DWORD what, DWORD val) goto scan_wait; /* Clear all waiting threads. Called from exceptions.cc prior to - * the main thread's dispatch to a signal handler function. - * (called from wait_sig thread) - */ + the main thread's dispatch to a signal handler function. + (called from wait_sig thread) */ case PROC_CLEARWAIT: /* Clear all "wait"ing threads. */ if (val) @@ -707,15 +706,20 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception) HANDLE hp = OpenProcess (PROCESS_DUP_HANDLE, false, p->dwProcessId); if (!hp) { + sigproc_printf ("OpenProcess failed, %E"); __seterrno (); goto out; } + for (int i = 0; !p->sendsig && i < 10000; i++) + low_priority_sleep (0); if (!DuplicateHandle (hp, p->sendsig, hMainProc, &sendsig, false, 0, DUPLICATE_SAME_ACCESS) || !sendsig) { + sigproc_printf ("DuplicateHandle failed, %E"); __seterrno (); goto out; } + CloseHandle (hp); pack.wakeup = NULL; } @@ -738,6 +742,7 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception) process is exiting. */ if (!its_me) { + sigproc_printf ("WriteFile for pipe %p failed, %E", sendsig); __seterrno (); ForceCloseHandle (sendsig); } @@ -784,6 +789,9 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception) rc = -1; } + if (wait_for_completion) + call_signal_handler_now (); + out: if (sig != __SIGPENDING) /* nothing */;