* exceptions.cc (set_signal_mask): Report on input argument rather than

getsigmask.
* fhandler.h (fhandler_base): Make friends with close_all_files.
* pinfo.cc (_pinfo::set_ctty): Add more debugging.
* sigproc.cc (proc_can_be_signalled): Detect state when signal handler thread
is gone in target process as an EPERM situation.  Set errno to ESRCH if process
doesn't exist.
(sigproc_terminate): Set sendsig to illegal value when closed.
(sig_send): Rely on proc_can_be_signalled setting the proper errno.
* syscalls.cc (close_all_files): Detect when all ttys are closed prior to
calling close_all_files.  The ctty needs to be closed explicitly in this case.
This commit is contained in:
Christopher Faylor
2003-12-16 23:28:03 +00:00
parent 0c3966ac4e
commit 1ed95be609
6 changed files with 47 additions and 9 deletions

View File

@ -248,9 +248,19 @@ proc_can_be_signalled (_pinfo *p)
return true;
}
return ISSTATE (p, PID_INITIALIZING) ||
(((p)->process_state & (PID_ACTIVE | PID_IN_USE)) ==
(PID_ACTIVE | PID_IN_USE));
if (p->sendsig == INVALID_HANDLE_VALUE)
{
set_errno (EPERM);
return false;
}
if (ISSTATE (p, PID_INITIALIZING) ||
(((p)->process_state & (PID_ACTIVE | PID_IN_USE)) ==
(PID_ACTIVE | PID_IN_USE)))
return true;
set_errno (ESRCH);
return false;
}
bool __stdcall
@ -638,7 +648,9 @@ sigproc_terminate (void)
sig_loop_wait = 0; // Tell wait_sig to exit when it is
// finished with anything it is doing
ForceCloseHandle (sigcomplete_main);
CloseHandle (myself->sendsig);
HANDLE sendsig = myself->sendsig;
myself->sendsig = INVALID_HANDLE_VALUE;
CloseHandle (sendsig);
}
proc_terminate (); // Terminate process handling thread
@ -679,7 +691,6 @@ sig_send (_pinfo *p, int sig, void *tls)
{
sigproc_printf ("invalid pid %d(%x), signal %d",
p->pid, p->process_state, sig);
set_errno (ESRCH);
goto out;
}