Page MenuHomeFreeBSD

D22621.id65278.diff
No OneTemporary

D22621.id65278.diff

Index: lib/libc/sys/kill.2
===================================================================
--- lib/libc/sys/kill.2
+++ lib/libc/sys/kill.2
@@ -28,7 +28,7 @@
.\" @(#)kill.2 8.3 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
-.Dd December 1, 2017
+.Dd December 1, 2019
.Dt KILL 2
.Os
.Sh NAME
@@ -105,12 +105,11 @@
.Xr init 8 ) ,
and the process sending the signal.
If the user is not the super user, the signal is sent to all processes
-with the same uid as the user excluding the process sending the signal.
+which the caller has permissions to, excluding the process sending the signal.
No error is returned if any process could be signaled.
.El
.Pp
-For compatibility with System V,
-if the process number is negative but not -1,
+If the process number is negative but not -1,
the signal is sent to all processes whose process group ID
is equal to the absolute value of the process number.
This is a variant of
@@ -134,7 +133,7 @@
.It Bq Er EPERM
The sending process does not have permission to send
.Va sig
-to the receiving process.
+to any receiving process.
.El
.Sh SEE ALSO
.Xr getpgrp 2 ,
Index: sys/kern/kern_sig.c
===================================================================
--- sys/kern/kern_sig.c
+++ sys/kern/kern_sig.c
@@ -1688,10 +1688,11 @@
{
struct proc *p;
struct pgrp *pgrp;
- int err;
- int ret;
+ int err, ret;
+ bool sent, found;
- ret = ESRCH;
+ ret = 0;
+ sent = found = false;
if (all) {
/*
* broadcast
@@ -1702,15 +1703,16 @@
p == td->td_proc || p->p_state == PRS_NEW) {
continue;
}
+ found = true;
PROC_LOCK(p);
err = p_cansignal(td, p, sig);
if (err == 0) {
- if (sig)
+ if (sig != 0)
pksignal(p, sig, ksi);
+ sent = true;
+ } else if (ret == 0 && err != ESRCH && err != EPERM) {
ret = err;
}
- else if (ret == ESRCH)
- ret = err;
PROC_UNLOCK(p);
}
sx_sunlock(&allproc_lock);
@@ -1737,18 +1739,22 @@
PROC_UNLOCK(p);
continue;
}
+ found = true;
err = p_cansignal(td, p, sig);
if (err == 0) {
- if (sig)
+ if (sig != 0)
pksignal(p, sig, ksi);
+ sent = true;
+ } else if (ret == 0 && err != ESRCH && err != EPERM) {
ret = err;
}
- else if (ret == ESRCH)
- ret = err;
PROC_UNLOCK(p);
}
PGRP_UNLOCK(pgrp);
}
+ MPASS(ret != 0 || found || !sent);
+ if (ret == 0 && !sent)
+ ret = found ? EPERM : ESRCH;
return (ret);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 28, 2:56 AM (2 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30455057
Default Alt Text
D22621.id65278.diff (2 KB)

Event Timeline