Experiment 1 – on the CLI, no frills

Follow the simple steps here:

  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, type this:
   $ exec ps

What do you notice? Can you explain it?

Hey, come on, please try it out first, and then read on. Yes, the terminal window process is the predecessor here; upon an exec it's overwritten by the successor process ps, which does its work and exits (you probably did not see the output as it disappeared too quickly). ps is the successor process, and, of course, we cannot return to the predecessor (the Terminal window)—ps has literally replaced its VAS. Thus, the Terminal window effectively disappears.

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.