** Reply to message from Otto Moerbeek <[EMAIL PROTECTED]> on Thu, 14 Jul
2005 16:15:11 +0200 (CEST)

>On Thu, 14 Jul 2005, Dave Anderson wrote:
>
>> It also, at least under OpenBSD, has the serious problem that "$$"
>> isn't the PID of the shell running the script but rather the PID of the
>> "original" shell (whatever exactly that means; some testing suggests
>> that it's the last process on the PPID chain which is still in this
>> process group) and I haven't yet found any straightforward way of
>> getting the PID of the "bottom-level" shell, which is what is needed
>> for the stale-lock testing to work at all when the exclusion needed is
>> among scripts run in subshells of the same shell.  (I realize that I
>> could create a trivial program which writes its PPID to stdout, or hack
>> /bin/sh to add a new variable which contains the PID I want -- but I'd
>> prefer to use the tools which come as part of the base system.  This
>> has also left me rather curious as to *why* the PID and PPID of the
>> "original" shell are easily accessible in scripts but those of the
>> subshell actually running the script aren't.)
>
>I did not check your script, but POSIX says this:
>
>$   Expands to the decimal process ID of the invoked shell. In a
>    subshell (see Shell Execution Environment ), '$' shall expand to the
>    same value as that of the current shell.
>
>There's a similar phrase in the man page,

Sorry if I was unclear -- it's certainly documented (though exactly
what "original" as used in the man page means wasn't totally obvious to
me without doing some testing); my curiosity is about the reasoning
behind making the PID/PPID of the "original" shell easily available
while leaving those of the subshell inaccessible.

        Dave

-- 
Dave Anderson
<[EMAIL PROTECTED]>

Reply via email to