bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: on interrupt, xargs does not wait for subprocess to exit


From: frederik
Subject: Re: on interrupt, xargs does not wait for subprocess to exit
Date: Thu, 27 Aug 2015 22:24:00 -0700
User-agent: Mutt/1.5.23+102 (2ca89bed6448) (2014-03-12)

On Thu, Aug 27, 2015 at 09:50:29PM -0400, Dale R. Worley wrote:
> Frederik Eaton <address@hidden> writes:
> > In brief:
> >
> >     $ seq 1 10 | xargs sh -c 'trap "" INT; sleep 3; echo hi'
> >     ^C
> >     [130]$ hi
> >
> > Notice that I pressed ^C and xargs exited, the shell prompt appeared,
> > some seconds later the word "hi" appeared.
> >
> > Is this the correct behavior for xargs? It could be somewhat annoying
> > in certain cases.
> >
> > I'm not currently subscribed so please Cc me!
> 
> I think it is typical behavior.  If I understand correctly, xargs does
> not propagate the ^C to its subprocesses.  Instead, the kernel sends the
> appropriate signal to all of the relevant descendants of the shell.  In
> this case, "seq", "xargs", "sh", and "sleep".  Actually, how things work
> with the descendants of the sub-shell, I don't know.  But in general,
> all of those processes will die in their own way, asychronously.

I see, and thank you for the reply.

I guess if xargs were to trap SIGINT and defer exiting, then it would
end up waiting for its sub-process to die, which should happen soon
anyway because the sub-process also receives SIGINT. I wonder if such
behavior would ever be objectionable. Perhaps it is not of great
importance to many people.

Frederick



reply via email to

[Prev in Thread] Current Thread [Next in Thread]