Summary
Here is a quick summary for you!
We have introduced some of the APIs dealing with UNIX process creation: fork()
, exec()
, and wait()
. However, we have just skimmed the surface. For more detail, read fork()
, and advocates for other, simpler process creation APIs such as spawn()
ASIDE: KEY PROCESS API TERMS
Each process has a name; in most systems, that name is a number known as a process ID (PID).
The
fork()
system call is used in UNIX systems to create a new process. The creator is called the parent; the newly created process is called the child., the child process is a nearly identical copy of the parent. As sometimes occurs in real life “They could be twins!” by Phoebe Jackson-Edwards. The Daily Mail. March 1, 2016. Available: www.dailymail.co.uk/femail/article-3469189/Photos-children-look- IDENTICAL-parents-age-sweep-web.html. This hard-hitting piece of journalism shows a bunch of weirdly similar child/parent photos and is frankly kind of mesmerizing. Go ahead, waste two minutes of your life and check it out. But don’t forget to come back here! This, in a microcosm, is the danger of surfing the web. The
wait()
system call allows a parent to wait for its child to complete execution.The
exec()
family of system calls allows a child to break free from its similarity to its parent and execute an entirely new program.A UNIX shell commonly uses
fork()
,wait()
, andexec()
to launch user commands; the separation of fork and exec enables features like input/output redirection, pipes, and other cool features, all without changing anything about the programs being run.Process control is available in the form of signals, which can cause jobs to stop, continue, or even terminate.
Which processes can be controlled by a particular person is encapsulated in the notion of a user; the operating system allows multiple users onto the system, and ensures users can only control their own processes.
A superuser can control all processes (and indeed do many other things); this role should be assumed infrequently and with caution for security reasons.
Get hands-on with 1400+ tech skills courses.