|Objective||Describe the mechanism by which processes come into being.|
grep yes *.cto his or her login shell. At this point, the shell needs to start a new grep process, wait for it to finish, then generate a new output prompt and wait for the next command. The mechanism by which this occurs is called forking.
fork(). This system call asks the operating system to clone whatever process calls it.
fork()call, the system replaces the shell process with two new processes. These processes are identical in every respect, except that one is labeled "parent" and the other is labeled "child." The parent process, which is identical to the original shell, then begins to wait for the child process to terminate.
fork()clones a process,
exec()starts a new process that replaces whatever process called it. In this instance, the child shell exec is the new grep process, and the child shell disappears, replaced by grep.
fork(), every process has a parent process--the process that called the
fork()that created it. Because all processes derive ultimately from init with PID 1, tracing the chain of ancestry back from any running process must ultimately lead to init.
killcommand. For example, to stop a process with the PID 34, you would type