O'Reilly logo

Advanced UNIX Programming by Warren W. Gay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Executing New Programs

While the fork(2) system call starts a clone of the current process, the programmer is still left needing a way to start a new executable program. The exec(2) family of functions fills this need.

When a new program is executed, the following general steps are performed:

  1. The kernel opens the new executable file for reading (and checks that the executable bit is set). An error is immediately returned to the caller if this fails.

  2. The same process ID and addressable memory is retained, while the current execution becomes suspended.

  3. The new program instructions are loaded from the executable file that has been opened by the kernel.

  4. Certain process flags and registers are reset (for example the stack pointer is reset).

  5. The execution ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required