Key points during an exec operation

The following sums up important points to note when a predecessor process execs a successor:

  • The successor process overwrites (or overlays) the predecessor's virtual address space.
    • In effect, the predecessor's text, data, library, and stack segments are now replaced by that of the successor's.
    • The OS will take care of the size adjustments.
  • No new process has been created—the successor now runs in the context of the old predecessor.
    • Several predecessor attributes (including but not limited to the PID and open files) thus get auto-inherited by the successor. (The astute reader could then question why, in our previous example, the PID of ps is not 3,396 ? Patience, please, we shall have the precise answer ...

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.