MCPcopy Create free account
hub / github.com/F-Stack/f-stack / kern_kill

Function kern_kill

freebsd/kern/kern_sig.c:1792–1838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1790}
1791
1792int
1793kern_kill(struct thread *td, pid_t pid, int signum)
1794{
1795 ksiginfo_t ksi;
1796 struct proc *p;
1797 int error;
1798
1799 /*
1800 * A process in capability mode can send signals only to himself.
1801 * The main rationale behind this is that abort(3) is implemented as
1802 * kill(getpid(), SIGABRT).
1803 */
1804 if (IN_CAPABILITY_MODE(td) && pid != td->td_proc->p_pid)
1805 return (ECAPMODE);
1806
1807 AUDIT_ARG_SIGNUM(signum);
1808 AUDIT_ARG_PID(pid);
1809 if ((u_int)signum > _SIG_MAXSIG)
1810 return (EINVAL);
1811
1812 ksiginfo_init(&ksi);
1813 ksi.ksi_signo = signum;
1814 ksi.ksi_code = SI_USER;
1815 ksi.ksi_pid = td->td_proc->p_pid;
1816 ksi.ksi_uid = td->td_ucred->cr_ruid;
1817
1818 if (pid > 0) {
1819 /* kill single process */
1820 if ((p = pfind_any(pid)) == NULL)
1821 return (ESRCH);
1822 AUDIT_ARG_PROCESS(p);
1823 error = p_cansignal(td, p, signum);
1824 if (error == 0 && signum)
1825 pksignal(p, signum, &ksi);
1826 PROC_UNLOCK(p);
1827 return (error);
1828 }
1829 switch (pid) {
1830 case -1: /* broadcast signal */
1831 return (killpg1(td, signum, 0, 1, &ksi));
1832 case 0: /* signal own process group */
1833 return (killpg1(td, signum, 0, 0, &ksi));
1834 default: /* negative explicit process group */
1835 return (killpg1(td, signum, -pid, 0, &ksi));
1836 }
1837 /* NOTREACHED */
1838}
1839
1840int
1841sys_pdkill(struct thread *td, struct pdkill_args *uap)

Callers 1

sys_killFunction · 0.85

Calls 4

p_cansignalFunction · 0.85
pksignalFunction · 0.85
killpg1Function · 0.85
pfind_anyFunction · 0.70

Tested by

no test coverage detected