From owner-svn-src-head@freebsd.org Tue Jul 14 12:16:15 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 913F699CCB9; Tue, 14 Jul 2015 12:16:15 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 67CC2AAD; Tue, 14 Jul 2015 12:16:15 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6ECGFG3063526; Tue, 14 Jul 2015 12:16:15 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6ECGF0T063525; Tue, 14 Jul 2015 12:16:15 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201507141216.t6ECGF0T063525@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Tue, 14 Jul 2015 12:16:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285535 - head/sys/compat/cloudabi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jul 2015 12:16:15 -0000 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 +#include +#include #include -#include -#include +#include #include @@ -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); }