Date: Mon, 29 Oct 2012 03:52:19 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r242284 - stable/7/sys/kern Message-ID: <201210290352.q9T3qJ9e070078@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: eadler Date: Mon Oct 29 03:52:19 2012 New Revision: 242284 URL: http://svn.freebsd.org/changeset/base/242284 Log: MFC r241855,r241859: Update the kill(2) and killpg(2) man pages to the modern permission checks. Also indicate killpg(2) is POSIX compliant. Correct the killpg(2) return values: Return EPERM if processes were found but they were unable to be signaled. Return the first error from p_cansignal if no signal was successful. Discussed with: jilles Approved by: cperciva (implicit) Modified: stable/7/sys/kern/kern_sig.c Directory Properties: stable/7/sys/ (props changed) Modified: stable/7/sys/kern/kern_sig.c ============================================================================== --- stable/7/sys/kern/kern_sig.c Mon Oct 29 03:52:18 2012 (r242283) +++ stable/7/sys/kern/kern_sig.c Mon Oct 29 03:52:19 2012 (r242284) @@ -1620,8 +1620,10 @@ killpg1(td, sig, pgid, all) { register struct proc *p; struct pgrp *pgrp; - int nfound = 0; + int err; + int ret; + ret = ESRCH; if (all) { /* * broadcast @@ -1634,11 +1636,14 @@ killpg1(td, sig, pgid, all) PROC_UNLOCK(p); continue; } - if (p_cansignal(td, p, sig) == 0) { - nfound++; + err = p_cansignal(td, p, sig); + if (err == 0) { if (sig) psignal(p, sig); + ret = err; } + else if (ret == ESRCH) + ret = err; PROC_UNLOCK(p); } sx_sunlock(&allproc_lock); @@ -1665,16 +1670,19 @@ killpg1(td, sig, pgid, all) PROC_UNLOCK(p); continue; } - if (p_cansignal(td, p, sig) == 0) { - nfound++; + err = p_cansignal(td, p, sig); + if (err == 0) { if (sig) psignal(p, sig); + ret = err; } + else if (ret == ESRCH) + ret = err; PROC_UNLOCK(p); } PGRP_UNLOCK(pgrp); } - return (nfound ? 0 : ESRCH); + return (ret); } #ifndef _SYS_SYSPROTO_H_
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210290352.q9T3qJ9e070078>