From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 14 20:25:08 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F2941065670 for ; Tue, 14 Feb 2012 20:25:08 +0000 (UTC) (envelope-from matthewstory@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 15EA88FC08 for ; Tue, 14 Feb 2012 20:25:07 +0000 (UTC) Received: by vcmm1 with SMTP id m1so404850vcm.13 for ; Tue, 14 Feb 2012 12:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=5gYqHVl2mRwe2yfwP4BuH2aa8ktgsUI8N2qsC1mL2a0=; b=REvFuFuLrjqtT1JXvx7nFzGE9Zi/gWm80zUIETLcUnX1QjRc2Ie1tDZr7w0n2VkHX+ NqymR1yf2v/MA5hvq/VbSpdnmLMXiiuHok3DUIXIKi4EHT/5A0aI5PgB/4S60HH7wwaY C8RrpiD9RwGu8JoOqxkh6hfwzh9Kdnnbka3mE= MIME-Version: 1.0 Received: by 10.220.38.10 with SMTP id z10mr12733385vcd.48.1329251107287; Tue, 14 Feb 2012 12:25:07 -0800 (PST) Received: by 10.52.21.84 with HTTP; Tue, 14 Feb 2012 12:25:07 -0800 (PST) In-Reply-To: References: <20120214193530.GA42580@stack.nl> Date: Tue, 14 Feb 2012 15:25:07 -0500 Message-ID: From: Matthew Story To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: xargs short-circuit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Feb 2012 20:25:08 -0000 On Tue, Feb 14, 2012 at 2:37 PM, Matthew Story wrote: > On Tue, Feb 14, 2012 at 2:35 PM, Jilles Tjoelker wrote: > >> On Tue, Feb 14, 2012 at 01:34:49PM -0500, Matthew Story wrote: >> > After reading the man-page, and browsing around the internet for a >> minute, >> > I was just wondering if there is an option in (any) xargs to >> short-circuit >> > on first failure of [utility [arguments]]. >> >> > e.g. >> >> > $ jot - 1 10 | xargs -e -n1 sh -c 'echo "$*"; echo exit 1' worker || >> echo $? >> > 1 >> > 1 >> >> > such that any non-0 exit code in a child process would cause xargs to >> stop >> > processing. seems like this would be a nice feature to have. >> >> As per xargs(1), you can do this by having the command exit on a signal >> or with a value of 255. >> > exit 255 with -P, and SIGTERM (with or without -P) causes FreeBSD xargs to orphan, is this desirable behavior? findutils xargs orphans on 255 and SIGTERM (with -P), but does not orphan without -P when SIGTERM is sent. I would expect xargs to propegate the signal, or wait, although the man page does say "immediately", the POSIX specification is less clear ... this makes it more-or-less unsuitable for my needs, but i guess i could do something like: ... | xargs sh -c '... exit 255;' if [ $? -ne 0 ]; then wait # cleanup exit 1 fi > > Yes indeed it does ... should have scoured further, thanks! > > >> >> -- >> Jilles Tjoelker >> > > > > -- > regards, > matt > -- regards, matt