Date: Fri, 28 Jan 2005 00:43:47 -0800 From: Julian Elischer <julian@elischer.org> To: Walter Belgers <walter+freebsd@belgers.com> Cc: Current <freebsd-current@freebsd.org> Subject: Re: sh bug? Message-ID: <41F9FB43.3080105@elischer.org> In-Reply-To: <20050128081953.GC98080@willempie.het.net.je> References: <41F9F2DC.7000907@elischer.org> <20050128081953.GC98080@willempie.het.net.je>
next in thread | previous in thread | raw e-mail | index | archive | help
Walter Belgers wrote: > Julian Elischer wrote: > >>however echo $$ >>and >> ( echo $$ ) > > > echo is a shell builting (same with ps). > Apparantly, sh is smart in recognising you are running sh/ps. > > $ echo $$ > 11808 > $ (echo $$) > 11808 > $ cat x > #!/bin/sh > echo $$ > $ (./x) > 11812 > > Walter. that doesn't prove anything... ./x would have given the same result. Actually I investigated further.. $ echo $$ 13472 $ ( > ps -l >/tmp/1 > cat /tmp/1 > ps -l >/tmp/2 > cat /tmp/2 > echo $$ > ) >/tmp/3 $ cat /tmp/3 [...] 1000 13472 8177 0 8 0 5484 496 wait S pa 0:00.01 /rescue/sh 1000 14482 13472 0 8 0 5484 496 wait S+ pa 0:00.00 /rescue/sh 1000 14483 14482 0 96 0 1412 756 - R+ pa 0:00.00 ps -l [...] this shows that it in fact does fork a different shell, but only if the contents of the group are "complicated enough". interestingly enough adding "echo $$" inside the group still prints the original value of 13472 and not 14482 which might be more truthful.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41F9FB43.3080105>