On 3/10/20 4:04 PM, Greg Wooledge wrote:
> On Tue, Mar 10, 2020 at 08:57:26PM +0100, Phi Debian wrote:
>> Secondly, if yuio insist on going on the subshell path, then $$ and $PPID
>> ought to be setup appropriately, here ther are plain bogus.
> 
> wooledg:~$ command_not_found_handle() { echo "\$\$=$$ BASHPID=$BASHPID"; }
> wooledg:~$ echo "\$\$=$$ BASHPID=$BASHPID"
> $$=859 BASHPID=859
> wooledg:~$ wyeiruwyer
> $$=859 BASHPID=15619
> 
> It looks correct to me.  $$ is the PID of the main script, and $BASHPID
> is the PID of the subshell.

I think perhaps what the reporter did not realize is that this is the
expected behavior of a subshell.

$ command_not_found_handle; (command_not_found_handle); sddssdfcdsfsf
$$=20819 BASHPID=20819
$$=20819 BASHPID=40810
$$=20819 BASHPID=40811

i.e. $$ doesn't change, whether invoked via command_not_found_handle or
any other form of subshell.

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to