in reply to Re^2: multi-command sytem call
in thread multi-command sytem call
The theory, quickly, goes like this.
Every process on the system gets a Process IDentifier (aka pid), which is an integer. For all operations, the pid identifies the process. If you launch a process with open, you're told that pid. When it exits, your process gets a CHLD signal. If you've not been set up to automatically ignore CHLD signals, you can then wait or waitpid to "reap" the child. When you call wait or waitpid, Perl tells you the pid of the process that you reaped and then puts its exit status into $?. Between the time that a process attempts to exit and when its parent reaps it, that process is a zombie - dead but not gone until it manages to tell someone its fate.
Yeah, it sounds complex. But if you sit down and try to write down what needs to happen, it generally works out to be reasonably straightforward.
The reason why you need to be aware of all of this complexity is that you're trying to launch two processes at once, then find out what happened to them later. In particular you want to know that one refused to run because the other was running. For that you need to use the API for dealing with multiple subprocesses and keeping them straight.
|
|---|