title: PID of all child processes of a command
body: <p>In a bash script, I want to launch a process in the foreground, then print a list of all the process names and PIDs that were started as children of that process. For example, suppose I have the following scripts, but I can only modify the first one:</p>
  
  <p>A.sh:</p>
  
  <pre><code>#!/bin/bash
  B.sh
  </code></pre>
  
  <p>B.sh:</p>
  
  <pre><code>#!/bin/bash
  C.sh
  </code></pre>
  
  <p>C.sh:</p>
  
  <pre><code>#!/bin/bash
  echo "Running C.sh"
  </code></pre>
  
  <p>Without modifying B.sh, C.sh or the echo command, and without starting any of the child processes in the background, I would like A.sh to print the following:</p>
  
  <pre><code>B.sh 1208
  C.sh 1210
  echo 1211
  </code></pre>
  
  <p>Can A.sh fork a process that records this information while the child processes are running in the foreground of A.sh?</p>