On Thu, Aug 27, 2015 at 09:50:29PM -0400, Dale R. Worley wrote: > Frederik Eaton <frede...@ofb.net> 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