Experiment 2 – on the CLI, again

This time, we'll make it easier on you! Follow the given steps:

  1. Fire up a shell (a Terminal window, typically, on a GUI-based Linux).
  2. In the window, or more precisely, at the shell prompt, run ps followed by bash —yes, we're spawning a subshell here, followed by ps once more. (Check out the next screenshot; notice the PIDs of the original and sub-shell Bash processes - 3,396 and 13,040.).
  3. On the sub-shell, exec the ps command; this ps successor process overwrites (or overlays) the process image of the predecessor process—the bash sub-shell.
  4. Observe the output: In the exec ps command output, the PID of ps is the PID of the bash subshell process: 13,040! This suggests that it's running in the context of that ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.