[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] Re: speed up gnulib-tool a bit

From: Eric Blake
Subject: Re: [bug-gnulib] Re: speed up gnulib-tool a bit
Date: Tue, 19 Sep 2006 06:51:16 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20060909 Thunderbird/ Mnenhy/

Hash: SHA1

According to Bruno Haible on 9/18/2006 9:20 AM:
> Ralf Wildenhues wrote:
>> Hmm, ok.  But traditional shells execute this construct
>>   while read foo
>>   do
>>     $whatever
>>   done <$file
>> in a subshell, too, for example Solaris 10 sh.
> Ouch. Looking at the variables, it indeed behaves like a subshell.
> Looking at the process id, it does not...!

This is to be expected - POSIX states that $$ is special, and that in a
subshell, it is not the pid of the current process, but the pid of the
original process.

"In a subshell (see Shell Execution Environment ), '$' shall expand to the
same value as that of the current shell."

"A subshell environment shall be created as a duplicate of the shell
environment, except that signal traps set by that shell environment shall
be set to the default values. Changes made to the subshell environment
shall not affect the shell environment. Command substitution, commands
that are grouped with parentheses, and asynchronous lists shall be
executed in a subshell environment. Additionally, each command of a
multi-command pipeline is in a subshell environment; as an extension,
however, any or all commands in a pipeline may be executed in the current
environment. All other commands shall be executed in the current shell

While you can use $SHLVL to tell whether you are in a subshell, and then
use a helper sub-process to report the ppid (and thus the subshell's pid),
there is no portable way to tell the pid of a subshell from within the

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


reply via email to

[Prev in Thread] Current Thread [Next in Thread]