| 163 | } |
| 164 | |
| 165 | static int |
| 166 | reap_status(struct thread *td, struct proc *p, |
| 167 | struct procctl_reaper_status *rs) |
| 168 | { |
| 169 | struct proc *reap, *p2, *first_p; |
| 170 | |
| 171 | sx_assert(&proctree_lock, SX_LOCKED); |
| 172 | bzero(rs, sizeof(*rs)); |
| 173 | if ((p->p_treeflag & P_TREE_REAPER) == 0) { |
| 174 | reap = p->p_reaper; |
| 175 | } else { |
| 176 | reap = p; |
| 177 | rs->rs_flags |= REAPER_STATUS_OWNED; |
| 178 | } |
| 179 | if (reap == initproc) |
| 180 | rs->rs_flags |= REAPER_STATUS_REALINIT; |
| 181 | rs->rs_reaper = reap->p_pid; |
| 182 | rs->rs_descendants = 0; |
| 183 | rs->rs_children = 0; |
| 184 | if (!LIST_EMPTY(&reap->p_reaplist)) { |
| 185 | first_p = LIST_FIRST(&reap->p_children); |
| 186 | if (first_p == NULL) |
| 187 | first_p = LIST_FIRST(&reap->p_reaplist); |
| 188 | rs->rs_pid = first_p->p_pid; |
| 189 | LIST_FOREACH(p2, &reap->p_reaplist, p_reapsibling) { |
| 190 | if (proc_realparent(p2) == reap) |
| 191 | rs->rs_children++; |
| 192 | rs->rs_descendants++; |
| 193 | } |
| 194 | } else { |
| 195 | rs->rs_pid = -1; |
| 196 | } |
| 197 | return (0); |
| 198 | } |
| 199 | |
| 200 | static int |
| 201 | reap_getpids(struct thread *td, struct proc *p, struct procctl_reaper_pids *rp) |
no test coverage detected