Example 1

In this code fragment, an application uses the fork() function to create a child process. The child then becomes the process group leader of a new process group that runs in the foreground and invokes the exec() function to run another application.