in UNIX, the fork() system call is used to create processes. fork() creates an identical copy of the calling process. After the fork(), the parent continues running concurrently with its child competing equally for the CPU. exec system call used after a fork to replace
the process' memory space with a new program.
cmd = readcmd();
pid = fork();
if (pid == 0) {
// Child process -- Setup environment here
// e.g., standard i/o, signals exec(cmd);
// exec doesn t return
} else {
// Parent process -- Wait for child to finish
wait(pid);
}