bug-gnulib
[Top][All Lists]
Advanced

[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:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.666

-----BEGIN PGP SIGNED MESSAGE-----
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.
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_05_02

"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
environment."

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
subshell.
http://lists.gnu.org/archive/html/bug-bash/2006-09/msg00068.html

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

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
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

iD8DBQFFD+fD84KuGfSFAYARAq3TAKDUd2GLiDNo1a4m0FRjo4Bv3pNeqgCeNunQ
w4vwGrZ/zzxPaHD8BBLfP1E=
=XQDL
-----END PGP SIGNATURE-----




reply via email to

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