killall.c (8d5ec3937c34b5fb3049b6d24abba97c009ce9d8) killall.c (40bcb503f1a8b9885072a7dc1cb41c2cc462469c)
1/*-
2 * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
3 * Copyright (c) 2000 Paul Saab <ps@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 76 unchanged lines hidden (view full) ---

85 warnx("unknown signal %s; valid signals:", name);
86 printsig(stderr);
87 exit(1);
88}
89
90int
91main(int ac, char **av)
92{
1/*-
2 * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
3 * Copyright (c) 2000 Paul Saab <ps@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 76 unchanged lines hidden (view full) ---

85 warnx("unknown signal %s; valid signals:", name);
86 printsig(stderr);
87 exit(1);
88}
89
90int
91main(int ac, char **av)
92{
93 struct kinfo_proc *procs = NULL, *newprocs;
93 struct kinfo_proc *procs, *newprocs;
94 struct stat sb;
95 struct passwd *pw;
96 regex_t rgx;
97 regmatch_t pmatch;
98 int i, j, ch;
99 char buf[256];
100 char first;
101 char *user = NULL;

--- 185 unchanged lines hidden (view full) ---

287 mib[3] = uid;
288 miblen = 4;
289 } else if (tty) {
290 mib[2] = KERN_PROC_TTY;
291 mib[3] = tdev;
292 miblen = 4;
293 }
294
94 struct stat sb;
95 struct passwd *pw;
96 regex_t rgx;
97 regmatch_t pmatch;
98 int i, j, ch;
99 char buf[256];
100 char first;
101 char *user = NULL;

--- 185 unchanged lines hidden (view full) ---

287 mib[3] = uid;
288 miblen = 4;
289 } else if (tty) {
290 mib[2] = KERN_PROC_TTY;
291 mib[3] = tdev;
292 miblen = 4;
293 }
294
295 procs = NULL;
295 st = sysctl(mib, miblen, NULL, &size, NULL, 0);
296 do {
297 size += size / 10;
298 newprocs = realloc(procs, size);
296 st = sysctl(mib, miblen, NULL, &size, NULL, 0);
297 do {
298 size += size / 10;
299 newprocs = realloc(procs, size);
299 if (newprocs == 0) {
300 if (procs)
301 free(procs);
302 errx(1, "could not reallocate memory");
300 if (newprocs == NULL) {
301 free(procs);
302 err(1, "could not reallocate memory");
303 }
304 procs = newprocs;
305 st = sysctl(mib, miblen, procs, &size, NULL, 0);
306 } while (st == -1 && errno == ENOMEM);
307 if (st == -1)
308 err(1, "could not sysctl(KERN_PROC)");
309 if (size % sizeof(struct kinfo_proc) != 0) {
310 fprintf(stderr, "proc size mismatch (%zu total, %zu chunks)\n",

--- 114 unchanged lines hidden ---
303 }
304 procs = newprocs;
305 st = sysctl(mib, miblen, procs, &size, NULL, 0);
306 } while (st == -1 && errno == ENOMEM);
307 if (st == -1)
308 err(1, "could not sysctl(KERN_PROC)");
309 if (size % sizeof(struct kinfo_proc) != 0) {
310 fprintf(stderr, "proc size mismatch (%zu total, %zu chunks)\n",

--- 114 unchanged lines hidden ---