Date: Sun, 21 Nov 2010 06:15:34 -0800 From: Garrett Cooper <gcooper@FreeBSD.org> To: Stephen McKay <mckay@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r215615 - head/usr.bin/xargs Message-ID: <AANLkTinPd1mQyZoFOU0mDqeTDwz%2B94NBpWA%2BM8uFzyn8@mail.gmail.com> In-Reply-To: <201011211055.oALAtG0q052310@svn.freebsd.org> References: <201011211055.oALAtG0q052310@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] On Sun, Nov 21, 2010 at 2:55 AM, Stephen McKay <mckay@freebsd.org> wrote: > Author: mckay > Date: Sun Nov 21 10:55:16 2010 > New Revision: 215615 > URL: http://svn.freebsd.org/changeset/base/215615 > > Log: > xargs can be fooled by exiting children that it did not start, causing > it to kick off a new command before the previous has finished, resulting > in corrupted (interleaved) output. It is also fooled by non-exiting > children it did not start, failing to exit until all extraneous children > have exited. > > This patch makes xargs keep track of children it starts, ignoring > pre-existing ones. Unfortunately this broke tinderbox and compile on HEAD. Could you please commit the following patch that fixes the compile and a handful of style(9) violations in the new code? Thanks! -Garrett [-- Attachment #2 --] Index: usr.bin/xargs/xargs.c =================================================================== --- usr.bin/xargs/xargs.c (revision 215636) +++ usr.bin/xargs/xargs.c (working copy) @@ -586,14 +586,14 @@ if (pids_empty()) { errno = ECHILD; - return -1; + return (-1); } while ((pid = waitpid(-1, status, block ? 0 : WNOHANG)) > 0) if (pids_remove(pid)) break; - return pid; + return (pid); } static void @@ -625,27 +625,27 @@ #define NOPID (0) static void -pids_init() +pids_init(void) { int i; if ((childpids = malloc(maxprocs * sizeof(*childpids))) == NULL) - errx(1, "malloc failed"); + errx(1, "malloc failed"); for (i = 0; i < maxprocs; i++) clearslot(i); } static int -pids_empty() +pids_empty(void) { - return curprocs == 0; + return (curprocs == 0); } static int -pids_full() +pids_full(void) { - return curprocs >= maxprocs; + return (curprocs >= maxprocs); } static void @@ -664,22 +664,22 @@ int slot; if ((slot = findslot(pid)) < 0) - return 0; + return (0); clearslot(slot); curprocs--; - return 1; + return (1); } static int -findfreeslot() +findfreeslot(void) { int slot; if ((slot = findslot(NOPID)) < 0) errx(1, "internal error: no free pid slot"); - return slot; + return (slot); } static int @@ -689,9 +689,9 @@ for (slot = 0; slot < maxprocs; slot++) if (childpids[slot] == pid) - return slot; + return (slot); - return -1; + return (-1); } static void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinPd1mQyZoFOU0mDqeTDwz%2B94NBpWA%2BM8uFzyn8>
