title: Why is $$ returning the same id as the parent process?
body: <p>I have problem with Bash, and I don't know why.<br />
  Under shell, I enter:</p>
  <pre><code>echo $$    ## print 2433
  (echo $$)  ## also print 2433
  (./getpid) ## print 2602
  </code></pre>
  <p>Where <code>getpid</code> is a C program to get current <em>pid</em>, like:</p>
  <blockquote>
  <pre><code>   int main() {
      printf(&quot;%d&quot;, (int)getpid());
      return 0;
     }
  </code></pre>
  </blockquote>
  <p>What confuses me is that:</p>
  <ol>
  <li>I think &quot;(command)&quot; is a sub-process (am i right?), and i think its <em>pid</em> should be different with its <em>parent pid</em>, but they are the same, why...</li>
  <li>When I use my program to show <em>pid</em> between parenthesis, the <em>pid</em> it shows is different, is it right?</li>
  <li>Is <code>$$</code> something like macro?</li>
  </ol>
  <p>Can you help me?</p>