Sat Feb 25 02:17:52 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>

* sysdeps/mach/hurd/kill.c: When the process has no message port
 	registered and we have its task port, translate a few signals to
 	task_suspend/task_resume/task_terminate.
This commit is contained in:
Roland McGrath 1995-02-25 11:33:49 +00:00
parent 22a1292a42
commit 3c46a92d40
2 changed files with 50 additions and 6 deletions

View File

@ -1,3 +1,9 @@
Sat Feb 25 02:17:52 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/mach/hurd/kill.c: When the process has no message port
registered and we have its task port, translate a few signals to
task_suspend/task_resume/task_terminate.
Fri Feb 24 14:40:48 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> Fri Feb 24 14:40:48 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* io/Makefile (routines): Add euidaccess. * io/Makefile (routines): Add euidaccess.

View File

@ -37,6 +37,8 @@ __kill (pid_t pid, int sig)
inline void kill_pid (pid_t pid) /* Kill one PID. */ inline void kill_pid (pid_t pid) /* Kill one PID. */
{ {
/* SIGKILL is not delivered as a normal signal. /* SIGKILL is not delivered as a normal signal.
Sending SIGKILL to a process means to terminate its task. */ Sending SIGKILL to a process means to terminate its task. */
if (sig == SIGKILL) if (sig == SIGKILL)
@ -58,12 +60,48 @@ __kill (pid_t pid, int sig)
} while (err == MACH_SEND_INVALID_DEST || } while (err == MACH_SEND_INVALID_DEST ||
err == MIG_SERVER_DIED); err == MIG_SERVER_DIED);
else else
{
error_t taskerr;
error_t kill_port (mach_port_t msgport, mach_port_t refport)
{
if (msgport != MACH_PORT_NULL)
/* Send a signal message to his message port. */
return __msg_sig_post (msgport, sig, refport);
/* The process has no message port. Perhaps try direct
frobnication of the task. */
if (taskerr)
/* If we could not get the task port, we can do nothing. */
return taskerr;
/* For user convenience in the case of a task that has
not registered any message port with the proc server,
translate a few signals to direct task operations. */
switch (sig)
{
/* The only signals that really make sense for an
unregistered task are kill, suspend, and continue. */
case SIGSTOP:
case SIGTSTP:
return __task_suspend (refport);
case SIGCONT:
return __task_resume (refport);
case SIGQUIT:
case SIGINT:
return __task_terminate (refport);
default:
/* We have full permission to send signals, but there is
no meaningful way to express this signal. */
return EPERM;
}
}
err = HURD_MSGPORT_RPC (__proc_getmsgport (proc, pid, &msgport), err = HURD_MSGPORT_RPC (__proc_getmsgport (proc, pid, &msgport),
__proc_pid2task (proc, pid, &refport) ? (taskerr = __proc_pid2task (proc, pid,
&refport)) ?
__proc_getsidport (proc, &refport) : 0, 1, __proc_getsidport (proc, &refport) : 0, 1,
/* If no msgport, we cannot send a signal. */ kill_port (msgport, refport));
msgport == MACH_PORT_NULL ? EPERM : }
__msg_sig_post (msgport, sig, refport));
if (! err) if (! err)
delivered = 1; delivered = 1;
} }