title: Sub-shell differences between bash and ksh
body: <p>I always believed that a sub-shell was not a child process, but another
  shell environment in the same process.</p>
  
  <p>I use a basic set of built-ins:</p>
  
  <pre><code>(echo "Hello";read)
  </code></pre>
  
  <p>On another terminal:</p>
  
  <pre><code>ps -t pts/0
    PID TTY          TIME CMD
  20104 pts/0    00:00:00 ksh
  </code></pre>
  
  <p>So, no child process in kornShell (ksh).  </p>
  
  <p>Enter bash, it appears to behave differently, given the same command:</p>
  
  <pre><code>  PID TTY          TIME CMD
   3458 pts/0    00:00:00 bash
  20067 pts/0    00:00:00 bash
  </code></pre>
  
  <p>So, a child process in bash.<br>
  From reading the man pages for bash, it is obvious that another process is created for a sub-shell,
  however it fakes $$, which is sneeky.</p>
  
  <p>Is this difference between bash and ksh expected, or am I reading the symptoms incorrectly?</p>
  
  <p>Edit: additional information:
  Running <code>strace -f</code> on bash and ksh on Linux shows that bash calls <code>clone</code> twice for the sample command (it does not call <code>fork</code>). So bash might be using threads (I tried <code>ltrace</code> but it core dumped!).
  KornShell calls neither <code>fork</code>, <code>vfork</code>, nor <code>clone</code>.</p>