** Unix process naming conventions **
I have a question about the UNIX naming conventions for child processes. Terms like orphan, zombie, and daemon seem kind of unusual. I was wondering what are the origins of this naming system. Were these just phrases that started getting used or were these terms intentionally set? Also, in a class lecture, Dr. Back mentions that these terms are outdated. Are there are any other terms used to refer to UNIX child processes and if not, is there any momentum in the community toward creating a new set of terms?
Interesting question. I think these terms arose over time. I checked Kernighan's biography and John Lion's commentary on Unix v6. The former doesn't mention any of these terms, the latter has some info about comments in the kernel code. I also looked at the 2018 POSIX version, e.g., this section on process termination, which uses the term zombie.
I think a plausible explanation may be this. First, there was the choice to have a hierarchical process structure that can be modeled as what computer scientists call a tree, which certainly predates Unix. From that, you inherit the family tree metaphors: parent, child, ancestor, descendant, and orphan fall into this category. Then you get into the fact that process management involves discussing the question of whether a process is still in progress or has completed, that's where the question of being "alive" or "dead" comes in, which in connection with parent/child can get unsavery. Although I think the word dead is not often used in the standards, mostly it's "terminated" - there is one occurrence in the man page for who(1).
As for zombie, Lion's cites the Oxford English Dictionary as "a corpse said to be revived by witchcraft" but this is of course misleading since zombie processes aren't going to be revived. In fact, this imaginery has confused peoples for decades. I recall our own sysadmin sending out a message asking everyone to kill their zombie processes so that they don't "bog down the machine." Zombie may still be a more palatable alternative than if we talked about corpses of processes, particularly to fans of horror movies.
As a side note, zombies were probably observed more often in earlier Unix systems as they are today. For many years, Unix implemented a "run child first" policy, and for multiple decades, most computers had only one CPU. So after the child process exited, a "zombie" record needed to be stored (often on disk). Linux changes to "parent runs first" in 2009, and of course on a multiprocessor, parent and child usually run simultaneously. This reduces the chance that a human would see the Z
in ps (except of course for buggy programs that fail to call wait()
).
The use of the word "daemon," which btw is the original Latin spelling of "demon," apparently dates back to the 1963 MAC system, described by Turing Award winner Fernando Corbató here in reference to Maxwell's daemon:
Our use of the word daemon was inspired by the Maxwell's daemon of physics and thermodynamics. (My background is Physics.) Maxwell's daemon was an imaginary agent which helped sort molecules of different speeds and worked tirelessly in the background. We fancifully began to use the word daemon to describe background processes which worked tirelessly to perform system chores."
As for the term "to reap" - I must admit that with not having had much English in high school, I learned many English words first through computing and popular culture. So to me "to reap" is associated with the Zombies reaped by Unix processes, but also with the Grim Reaper, and less with agriculture. But "to reap" of course also simply means "to harvest" and that's probably a more innocuous explanation. Keep in mind that a common case is for a parent process to fork a child process, for the child process to perform a task (such as gcc compiling a program), and then for the child to determine if the task was successful, and then to exit(s)
with a status code s
describing the success or failure of the task, namely 0 or 1, respectively. "Reaping the child" here simply means to harvest (as in obtain or access) the result of the task for which the parent forked the child process. I'm curious if others associate "reaping" also more with the Grim Reaper than a farm worker.