svn commit: r285535 - head/sys/compat/cloudabi
Ed Schouten
ed at FreeBSD.org
Tue Jul 14 12:16:15 UTC 2015
Author: ed
Date: Tue Jul 14 12:16:14 2015
New Revision: 285535
URL: https://svnweb.freebsd.org/changeset/base/285535
Log:
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
Modified:
head/sys/compat/cloudabi/cloudabi_proc.c
Modified: head/sys/compat/cloudabi/cloudabi_proc.c
==============================================================================
--- head/sys/compat/cloudabi/cloudabi_proc.c Tue Jul 14 12:02:56 2015 (r285534)
+++ head/sys/compat/cloudabi/cloudabi_proc.c Tue Jul 14 12:16:14 2015 (r285535)
@@ -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 *t
[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);
}
More information about the svn-src-all
mailing list