Pipes, Forks, and Zombies
6 hours ago
- #Process Management
- #Unix Systems
- #Pipes
- Pipes were conceptualized by Doug McIlroy in 1964 as a way to connect programs flexibly, like garden hoses.
- Literative Programming, introduced by Don Knuth, combines writing prose with code, but it faced overhead issues; McIlroy solved similar problems efficiently with shell pipes.
- Pipes automatically kill programs (via SIGPIPE) when output is no longer needed, as demonstrated with the seq program piped to less.
- Pipes can be used to implement a blocking mechanism similar to waitpid by closing write ends and reading from the pipe until a child process exits.
- Processes are organized in a hierarchy with init (pid 1) as the root, which collects orphaned children to prevent resource leaks.
- Zombie processes occur when a terminated process hasn't been waited on by its parent, consuming process IDs until reclaimed by init.