Let proc_raise() call into pksignal() directly.

Summary:
As discussed with kib@ in response to r285404, don't call into
kern_sigaction() within proc_raise() to reset the signal to the default
action before delivery. We'd better do that during image execution.

Change the code to simply use pksignal(), so we don't waste cycles on
functions like pfind() to look up the currently running process itself.

Test Plan:
This change has also been pushed into the cloudabi branch on GitHub. The
raise() tests still seem to pass.

Reviewers: kib

Reviewed By: kib

Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D3076
This commit is contained in:
Ed Schouten 2015-07-14 12:16:14 +00:00
parent d1be8e59e2
commit f9675092b8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285535

View File

@ -27,9 +27,10 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/syscallsubr.h>
#include <sys/sysproto.h>
#include <sys/signalvar.h>
#include <compat/cloudabi/cloudabi_proto.h>
@ -92,21 +93,22 @@ cloudabi_sys_proc_raise(struct thread *td,
[CLOUDABI_SIGXCPU] = SIGXCPU,
[CLOUDABI_SIGXFSZ] = SIGXFSZ,
};
static const struct sigaction sigdfl = {
.sa_handler = SIG_DFL,
};
struct kill_args kill_args = {
.pid = td->td_proc->p_pid,
};
ksiginfo_t ksi;
struct proc *p;
if (uap->sig >= nitems(signals) ||
(uap->sig != 0 && signals[uap->sig] == 0)) {
/* Invalid signal. */
return (EINVAL);
if (uap->sig >= nitems(signals) || signals[uap->sig] == 0) {
/* Invalid signal, or the null signal. */
return (uap->sig == 0 ? 0 : EINVAL);
}
kill_args.signum = signals[uap->sig];
/* Restore to default signal action and send signal. */
kern_sigaction(td, kill_args.signum, &sigdfl, NULL, 0);
return (sys_kill(td, &kill_args));
p = td->td_proc;
ksiginfo_init(&ksi);
ksi.ksi_signo = signals[uap->sig];
ksi.ksi_code = SI_USER;
ksi.ksi_pid = p->p_pid;
ksi.ksi_uid = td->td_ucred->cr_ruid;
PROC_LOCK(p);
pksignal(p, ksi.ksi_signo, &ksi);
PROC_UNLOCK(p);
return (0);
}