Executing a command starts a process that is numbered and tracked by the operating system. Processes are always generated by other processes. For example, log in to your system running a shell, then use an editor such as vi(1). Take the option of invoking the shell from vi(1). Execute ps(1) and you see a display resembling this (which shows the results of ps -f):
UID | PID | PPID | C | STIME | TTY | TIME | CMD |
---|---|---|---|---|---|---|---|
abc | 24210 | 1 | 0 | 06:13:14 | tty29 | 0:05 | -sh |
abc | 24631 | 24210 | 0 | 06:59:07 | tty29 | 0:13 | vi c2 |
abc | 28441 | 28358 | 80 | 09:17:22 | tty29 | 0:01 | ps -f |
abc | 28358 | 24631 | 2 | 09:15:14 | tty29 | 0:01 | sh -i |
User abc has four processes active. The process ID (PID) and parent process ID (PPID) columns show that the shell that started when user abc logged on is process 24210; its parent is the initialization process (process ID 1). Process 24210 is the parent of process 24631, and so on.
A program might need to run one or more other programs based on conditions it encounters. Reasons that you might not want to create one large executable include:
You might want to execute two, or more, of the modules concurrently.
The load module might get too big to fit in the maximum process size for your system.
You might not have control over the object code of all the other modules you want to include.
The fork(2) and exec(2) functions let you create a new process (a copy of the creating process) and start a new executable in place of the running one.