| 1790 | } |
| 1791 | |
| 1792 | int |
| 1793 | kern_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 | |
| 1840 | int |
| 1841 | sys_pdkill(struct thread *td, struct pdkill_args *uap) |
no test coverage detected