Date: Tue, 3 Jul 2012 08:46:26 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r238064 - stable/8/usr.bin/killall Message-ID: <201207030846.q638kQD6032008@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Tue Jul 3 08:46:26 2012 New Revision: 238064 URL: http://svn.freebsd.org/changeset/base/238064 Log: MFC r237844, r237845, r237846: Minor tweaks. Modified: stable/8/usr.bin/killall/killall.c Directory Properties: stable/8/usr.bin/killall/ (props changed) Modified: stable/8/usr.bin/killall/killall.c ============================================================================== --- stable/8/usr.bin/killall/killall.c Tue Jul 3 08:42:48 2012 (r238063) +++ stable/8/usr.bin/killall/killall.c Tue Jul 3 08:46:26 2012 (r238064) @@ -102,7 +102,7 @@ nosig(char *name) int main(int ac, char **av) { - struct kinfo_proc *procs = NULL, *newprocs; + struct kinfo_proc *procs, *newprocs; struct stat sb; struct passwd *pw; regex_t rgx; @@ -285,9 +285,6 @@ main(int ac, char **av) size = 0; mib[0] = CTL_KERN; mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PROC; - mib[3] = 0; - miblen = 3; if (user) { mib[2] = eflag ? KERN_PROC_UID : KERN_PROC_RUID; @@ -297,16 +294,20 @@ main(int ac, char **av) mib[2] = KERN_PROC_TTY; mib[3] = tdev; miblen = 4; + } else { + mib[2] = KERN_PROC_PROC; + mib[3] = 0; + miblen = 3; } + procs = NULL; st = sysctl(mib, miblen, NULL, &size, NULL, 0); do { size += size / 10; newprocs = realloc(procs, size); - if (newprocs == 0) { - if (procs) - free(procs); - errx(1, "could not reallocate memory"); + if (newprocs == NULL) { + free(procs); + err(1, "could not reallocate memory"); } procs = newprocs; st = sysctl(mib, miblen, procs, &size, NULL, 0); @@ -316,7 +317,7 @@ main(int ac, char **av) if (size % sizeof(struct kinfo_proc) != 0) { fprintf(stderr, "proc size mismatch (%zu total, %zu chunks)\n", size, sizeof(struct kinfo_proc)); - fprintf(stderr, "userland out of sync with kernel, recompile libkvm etc\n"); + fprintf(stderr, "userland out of sync with kernel\n"); exit(1); } nprocs = size / sizeof(struct kinfo_proc);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207030846.q638kQD6032008>