bug-bash
[Top][All Lists]
Advanced

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

Re: Bash cannot kill itself?


From: Jan Schampera
Subject: Re: Bash cannot kill itself?
Date: Wed, 30 Jun 2010 07:40:38 +0200
User-agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100329)

Clark J. Wang wrote:

Running a cmd in background (by &) would not create subshell. Simple
testing:

#!/bin/bash

function foo()
{
    echo $$
}

echo $$
foo &

### END OF SCRIPT ###

The 2 $$s output the same.

This doesn't mean that it doesn't create a subshell. It creates one, since it can't replace your foreground process.

It just shows that $$ does what it should do, it reports the relevant PID of the parent ("main") shell you use. As far as I can see, this applies to all kinds of subshells like
- explicit ones (...)
- pipeline components
- command substitution
- process substitution
- async shells (like above, running your function)
- ...

J.



reply via email to

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