O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

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

exec

Most often after a fork, you just want to run some other program. The exec() family of functions replaces the current running process with a new one. You will typically hear of fork() and exec() spoken of together, since they are rarely used apart from each other.

There are several variants of exec() depending on how you specify the file to run, how you specify the program arguments, and how you specify the environment variables for the new program.

Table 18.1. exec() Variants

 Finding the ExecutableProgram ArgumentsEnvironment
execlgiven pathNULL-terminated argument listenvironment inherited
execlpPATH searchNULL-terminated argument listenvironment inherited
execlegiven pathlist of argumentsexplicit environment (NULL-terminated string array) ...

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