1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-01 12:19:28 +00:00

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.

Reviewed by:	jilles
Approved by:	cperciva
MFC after:	1 week
This commit is contained in:
Eitan Adler 2012-10-22 03:34:43 +00:00
parent 1d1d4a4727
commit 2a1c0e4d4e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=241853

View File

@ -1599,8 +1599,10 @@ killpg1(struct thread *td, int sig, int pgid, int all, ksiginfo_t *ksi)
{
struct proc *p;
struct pgrp *pgrp;
int nfound = 0;
int err;
int ret;
ret = ESRCH;
if (all) {
/*
* broadcast
@ -1613,11 +1615,14 @@ killpg1(struct thread *td, int sig, int pgid, int all, ksiginfo_t *ksi)
PROC_UNLOCK(p);
continue;
}
if (p_cansignal(td, p, sig) == 0) {
nfound++;
err = p_cansignal(td, p, sig);
if (err == 0) {
if (sig)
pksignal(p, sig, ksi);
ret = err;
}
else if (ret == ESRCH)
ret = err;
PROC_UNLOCK(p);
}
sx_sunlock(&allproc_lock);
@ -1644,16 +1649,20 @@ killpg1(struct thread *td, int sig, int pgid, int all, ksiginfo_t *ksi)
PROC_UNLOCK(p);
continue;
}
if (p_cansignal(td, p, sig) == 0) {
nfound++;
err = p_cansignal(td, p, sig);
if (err == 0) {
if (sig)
pksignal(p, sig, ksi);
}
if (err == 0)
ret = err;
else if (ret == ESRCH)
ret = err;
PROC_UNLOCK(p);
}
PGRP_UNLOCK(pgrp);
}
return (nfound ? 0 : ESRCH);
return (ret);
}
#ifndef _SYS_SYSPROTO_H_