From owner-freebsd-current@FreeBSD.ORG Fri Jan 28 08:44:12 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6D9016A4CE for ; Fri, 28 Jan 2005 08:44:12 +0000 (GMT) Received: from pimout3-ext.prodigy.net (pimout3-ext.prodigy.net [207.115.63.102]) by mx1.FreeBSD.org (Postfix) with ESMTP id 334A143D41 for ; Fri, 28 Jan 2005 08:44:12 +0000 (GMT) (envelope-from julian@elischer.org) Received: from [192.168.1.102] (adsl-216-100-134-143.dsl.snfc21.pacbell.net [216.100.134.143])j0S8hooB362340; Fri, 28 Jan 2005 03:44:07 -0500 Message-ID: <41F9FB43.3080105@elischer.org> Date: Fri, 28 Jan 2005 00:43:47 -0800 From: Julian Elischer User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8a3) Gecko/20041017 X-Accept-Language: en, hu MIME-Version: 1.0 To: Walter Belgers References: <41F9F2DC.7000907@elischer.org> <20050128081953.GC98080@willempie.het.net.je> In-Reply-To: <20050128081953.GC98080@willempie.het.net.je> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: Current Subject: Re: sh bug? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2005 08:44:12 -0000 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.