Skip to content
Latchkey

What Is the Exec System Call?

The exec system call loads a new program into the calling process, replacing its memory image and starting the new program from its entry point. The process ID and many descriptors are preserved, but the previous code and data are discarded. It is typically used right after a fork so the child runs a different program.

Why it matters

The fork-then-exec pair is how shells launch every external command in a build. Knowing exec preserves the process ID explains why redirections set up before it carry into the new program.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →