| 198 | } |
| 199 | |
| 200 | static int |
| 201 | reap_getpids(struct thread *td, struct proc *p, struct procctl_reaper_pids *rp) |
| 202 | { |
| 203 | struct proc *reap, *p2; |
| 204 | struct procctl_reaper_pidinfo *pi, *pip; |
| 205 | u_int i, n; |
| 206 | int error; |
| 207 | |
| 208 | sx_assert(&proctree_lock, SX_LOCKED); |
| 209 | PROC_UNLOCK(p); |
| 210 | reap = (p->p_treeflag & P_TREE_REAPER) == 0 ? p->p_reaper : p; |
| 211 | n = i = 0; |
| 212 | error = 0; |
| 213 | LIST_FOREACH(p2, &reap->p_reaplist, p_reapsibling) |
| 214 | n++; |
| 215 | sx_unlock(&proctree_lock); |
| 216 | if (rp->rp_count < n) |
| 217 | n = rp->rp_count; |
| 218 | pi = malloc(n * sizeof(*pi), M_TEMP, M_WAITOK); |
| 219 | sx_slock(&proctree_lock); |
| 220 | LIST_FOREACH(p2, &reap->p_reaplist, p_reapsibling) { |
| 221 | if (i == n) |
| 222 | break; |
| 223 | pip = &pi[i]; |
| 224 | bzero(pip, sizeof(*pip)); |
| 225 | pip->pi_pid = p2->p_pid; |
| 226 | pip->pi_subtree = p2->p_reapsubtree; |
| 227 | pip->pi_flags = REAPER_PIDINFO_VALID; |
| 228 | if (proc_realparent(p2) == reap) |
| 229 | pip->pi_flags |= REAPER_PIDINFO_CHILD; |
| 230 | if ((p2->p_treeflag & P_TREE_REAPER) != 0) |
| 231 | pip->pi_flags |= REAPER_PIDINFO_REAPER; |
| 232 | i++; |
| 233 | } |
| 234 | sx_sunlock(&proctree_lock); |
| 235 | error = copyout(pi, rp->rp_pids, i * sizeof(*pi)); |
| 236 | free(pi, M_TEMP); |
| 237 | sx_slock(&proctree_lock); |
| 238 | PROC_LOCK(p); |
| 239 | return (error); |
| 240 | } |
| 241 | |
| 242 | static void |
| 243 | reap_kill_proc(struct thread *td, struct proc *p2, ksiginfo_t *ksi, |
no test coverage detected