Date: Wed, 25 Jun 2003 00:41:51 -0700 From: John-Mark Gurney <gurney_j@efn.org> To: Juli Mallett <jmallett@freebsd.org>, "Tim J. Robbins" <tjr@freebsd.org>, freebsd-current@freebsd.org, Andrey Chernov <ache@nagual.pp.ru> Subject: Re: tcsh being dodgy, or pipe code ishoos? Message-ID: <20030625074151.GY57612@funkthat.com> In-Reply-To: <20030625060450.GX57612@funkthat.com> References: <20030624183515.A42570@FreeBSD.org> <1056499632.662.7.camel@timon.nist> <3EF922BE.4070803@acm.org> <20030624234707.A59666@FreeBSD.org> <20030625001525.A60867@FreeBSD.org> <20030625060450.GX57612@funkthat.com>
next in thread | previous in thread | raw e-mail | index | archive | help
John-Mark Gurney wrote this message on Tue, Jun 24, 2003 at 23:04 -0700: > Ok, I seem to have found out that we are reaping a child that we don't > know about. slightly modified xargs produces this: ok, with some magic ktrace work, I have come up with an more complete answer to the riddle. It's how the shell exec's the processes. The bare cause can be demo'd by: > ( ( echo 2 ; echo 3 ) | ./xargs -I% echo + % ) Say the shell you run the above command is 10. It will fork to create a shell to run the commands in the outter parens. Call this 11. 11's job is to run: (echo 2; echo 3) | ./xargs -I% echo +% 11 will fork/exec and run: echo 2; echo 3 creating process 12. 11 will see that there is no additional commands after ./xargs, and exec (not fork) xargs. Since 12 is stil around and a child of 11, when it exits, 11 will reap 12, and thinking that the first proccess has exited, run the second echo command. Due to scheduling, we'll have two processes running at the same time which can cause the interleaving of data. So, now the question is, do we fix xargs to deal with unexpected children? Or fix the shells in question? (tcsh and zsh seem to suffer this problem) To me, fixing xargs is correct since it prevents another possible future abusers of this "feature". -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030625074151.GY57612>