| 66 | } |
| 67 | |
| 68 | struct kinfo_proc * |
| 69 | kinfo_getallproc(int *cntp) |
| 70 | { |
| 71 | struct kinfo_proc *kipp; |
| 72 | size_t len; |
| 73 | int mib[3]; |
| 74 | |
| 75 | mib[0] = CTL_KERN; |
| 76 | mib[1] = KERN_PROC; |
| 77 | mib[2] = KERN_PROC_PROC; |
| 78 | |
| 79 | len = 0; |
| 80 | if (sysctl(mib, nitems(mib), NULL, &len, NULL, 0) < 0) |
| 81 | return (NULL); |
| 82 | |
| 83 | kipp = malloc(len); |
| 84 | if (kipp == NULL) |
| 85 | return (NULL); |
| 86 | |
| 87 | if (sysctl(mib, nitems(mib), kipp, &len, NULL, 0) < 0) |
| 88 | goto bad; |
| 89 | if (len % sizeof(*kipp) != 0) |
| 90 | goto bad; |
| 91 | if (kipp->ki_structsize != sizeof(*kipp)) |
| 92 | goto bad; |
| 93 | *cntp = len / sizeof(*kipp); |
| 94 | kinfo_proc_sort(kipp, len / sizeof(*kipp)); |
| 95 | return (kipp); |
| 96 | bad: |
| 97 | *cntp = 0; |
| 98 | free(kipp); |
| 99 | return (NULL); |
| 100 | } |
nothing calls this directly
no test coverage detected