From owner-freebsd-current@FreeBSD.ORG Fri Jan 28 17:14:36 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 6612F16A4CE; Fri, 28 Jan 2005 17:14:36 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0BB2143D54; Fri, 28 Jan 2005 17:14:36 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.1) id j0SHETsn094296; Fri, 28 Jan 2005 11:14:29 -0600 (CST) (envelope-from dan) Date: Fri, 28 Jan 2005 11:14:29 -0600 From: Dan Nelson To: Julian Elischer Message-ID: <20050128171429.GB70503@dan.emsphone.com> References: <41F9F2DC.7000907@elischer.org> <20050128094116.B56848@beagle.kn.op.dlr.de> <41FA008D.7030403@elischer.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41FA008D.7030403@elischer.org> X-OS: FreeBSD 5.3-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: Current cc: Harti Brandt 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 17:14:36 -0000 In the last episode (Jan 28), Julian Elischer said: > Harti Brandt wrote: > >On Fri, 28 Jan 2005, Julian Elischer wrote: > > > >JE>however echo $$ > >JE>and > >JE> ( echo $$ ) > >JE> > >JE>produce the same result. > > > >I think that the $$ is expanded in the old shell in any case. > > hence my test of > ps -l vs (ps -l) > > unfortunatly the shell short circuits that too if it's too simple. I think POSIX is careful to define a "subshell" as "a duplicate of the shell environment [... where] changes made are not visible to the parent shell environment". They don't mention forking processes, which allows shell authors to skip forking a separate shell process if they can determine that there's no need for one. I don't think there's any way for a subshell to determine its own pid if you know it's running in another process, even if it's an asynchronous one. At least the parent knows that pid, though, via $!. -- Dan Nelson dnelson@allantgroup.com