Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Mar 2012 21:39:04 -0400
From:      Matthew Story <matthewstory@gmail.com>
To:        freebsd-arch@freebsd.org
Cc:        Jilles Tjoelker <jilles@stack.nl>
Subject:   Re: Change to xargs to avoid orphaning of utility processes on signal|exit 255 from child
Message-ID:  <CAB%2B9ogfLz9i6mBi5H4%2Be7_T5ZgBWFBOUiJxJgdpDanxiHbVJrQ@mail.gmail.com>
In-Reply-To: <CAB%2B9ogedvEX-Au4Qw_sVczxOYB70yuYiiY8jh1i5gxq1W7rOXQ@mail.gmail.com>
References:  <CAB%2B9ogetrht1Ttf53vSbq7L5Fe9DbB5igSynKM3=tjZh0z0_ew@mail.gmail.com> <CAB%2B9ogcVr-pNof-Tncc6F8CKjm3suqt=U-zvy9We0YEouwxhFw@mail.gmail.com> <20120309225433.GA32725@stack.nl> <CAB%2B9ogdEUa3Q=jBDX-JeX1S7O_95E8MVc8XK2F7y8P0zcTaqiQ@mail.gmail.com> <CAB%2B9ogev5ksni%2Bfab_kFWyak_2HxNiaGpyaQnRMDr6Yduea_ig@mail.gmail.com> <CAB%2B9ogedvEX-Au4Qw_sVczxOYB70yuYiiY8jh1i5gxq1W7rOXQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--20cf3071c6aab94b5904bb01ce45
Content-Type: text/plain; charset=ISO-8859-1

On Sat, Mar 10, 2012 at 1:23 PM, Matthew Story <matthewstory@gmail.com>wrote:

> On Fri, Mar 9, 2012 at 11:27 PM, Matthew Story <matthewstory@gmail.com>wrote:
>
>> On Fri, Mar 9, 2012 at 6:13 PM, Matthew Story <matthewstory@gmail.com>wrote:
>>
>>>  On Fri, Mar 9, 2012 at 5:54 PM, Jilles Tjoelker <jilles@stack.nl>wrote:
>>>
>>>> On Tue, Feb 21, 2012 at 12:50:19PM -0500, Matthew Story wrote:
>>>> > On Thu, Feb 16, 2012 at 7:09 PM, Matthew Story <
>>>> matthewstory@gmail.com>wrote:
>>>> > > Apologies if this is the wrong list, I would like to submit a patch
>>>> that
>>>> > > changes the behavior of xargs(1) on signal to child utility process
>>>> or
>>>> > > child utility process exiting 255.  The patch(es) is|are available
>>>> here:
>>>>
>>>> [...snip]
>>>>
>>>> > This would cause xargs to wait on children if the command line cannot
>>>> be
>>>> > assembled, or utility cannot be invoked, in addition to the 2 cases
>>>> covered
>>>> > by the patch.  This should leave termination via signal to the xargs
>>>>
>>>  > process itself as the only outstanding case where xargs orphans
>>>> utilities,
>>>> > which is congruent with sh(1) behavior, and still allows for
>>>> signaling all
>>>> > processes via signal to the process group, if you actually desire to
>>>> signal
>>>> > all utility processes, along with xargs itself.  Thoughts?
>>>>
>>>> I think that makes sense.
>>>>
>>>> I updated the patch to the recent changes in -current and changed a
>>>> local from short to int:
>>>> [...snip]
>>>
>>>  changes look good to me, thanks for cleaning it up for -CURRENT.  I
>>> will provide an additional patch to cover waiting for the other 2 cases
>>> (cannot assemble, or cannot invoke) later tonight after some more testing.
>>>  [...snip]
>>>
>>
>> I believe I have finished removing the orphan cases for the assembly
>> failure and invocation failure cases,  updated patch attached for review,
>> also available here
>>
>>
>> http://axe0.blackskyresearch.net/patches/matt/xargs.no_orphan.full.patch.txt
>>
>
> Updated this patch (also attached), to consolidate all waitchildren, exit
> to use xexit, and tidied up a multiple warning condition on childerr to
> warn only once while waiting to exit.
>

Sorry for the noisy updates, but i made the same branching mistake here as
in my very first patch, let me know if there are any more issues with this
one.  (updated the above link, along with attachment).


>
>
>>
>> This patch includes the cleaned-up changes Jilles sent back earlier
>> (thanks again).
>>
>> --
>> regards,
>> matt
>>
>
>
>
> --
> regards,
> matt
>



-- 
regards,
matt

--20cf3071c6aab94b5904bb01ce45
Content-Type: text/plain; charset=US-ASCII;
	name="xargs.no_orphan.full.patch.txt"
Content-Disposition: attachment; filename="xargs.no_orphan.full.patch.txt"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gzoug4sf1

SW5kZXg6IHhhcmdzLjEKPT09PT09PT09PT09PT09PT09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cyIsIG5hbWUpOworCQl9IGVsc2UgaWYgKFdJRlNJR05BTEVEKHN0YXR1
cykpIHsKKwkJCXdhaXRhbGwgPSBjYXVzZV9leGl0ID0gMTsKKwkJCXdhcm54KCIlczogdGVybWlu
YXRlZCB3aXRoIHNpZ25hbCAlZDsgYWJvcnRpbmciLAogCQkJICAgIG5hbWUsIFdURVJNU0lHKHN0
YXR1cykpOwotCQlpZiAoV0VYSVRTVEFUVVMoc3RhdHVzKSA9PSAyNTUpCi0JCQllcnJ4KDEsICIl
czogZXhpdGVkIHdpdGggc3RhdHVzIDI1NTsgYWJvcnRpbmciLCBuYW1lKTsKLQkJaWYgKFdFWElU
U1RBVFVTKHN0YXR1cykpCi0JCQlydmFsID0gMTsKKwkJfSBlbHNlIGlmIChXRVhJVFNUQVRVUyhz
dGF0dXMpID09IDI1NSkgeworCQkJd2FpdGFsbCA9IGNhdXNlX2V4aXQgPSAxOworCQkJd2Fybngo
IiVzOiBleGl0ZWQgd2l0aCBzdGF0dXMgMjU1OyBhYm9ydGluZyIsIG5hbWUpOworCQl9IGVsc2Ug
aWYgKFdFWElUU1RBVFVTKHN0YXR1cykpCisgCQkJcnZhbCA9IDE7CiAJfQogCisgCWlmIChjYXVz
ZV9leGl0KQorCQlleGl0KGNhdXNlX2V4aXQpOwogCWlmIChwaWQgPT0gLTEgJiYgZXJybm8gIT0g
RUNISUxEKQogCQllcnIoMSwgIndhaXRwaWQiKTsKIH0K
--20cf3071c6aab94b5904bb01ce45--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAB%2B9ogfLz9i6mBi5H4%2Be7_T5ZgBWFBOUiJxJgdpDanxiHbVJrQ>