[This post notes differences between the fifth and sixth editions.]
“Process Management” has been one of our neglected chapters for updates, being much the same in the fifth edition as it was in the third. It’s at the end of the book and it doesn’t immediately assert itself as a chapter needing work like a chapter on regular expressions does. We don’t often think about new features in interprocess communication, at least until now.
We didn’t really have to change anything big, but there are a lot of additional examples for signals and piped opens. A lot has happened in those areas since we last added to this chapter.
In the fifth edition, we had a lot of words to warn about “unsafe signals”. Way back in Perl 5.7.3 (yes, before the fourth edition!), Perl moved to deferred signals. And, although the fourth edition covers Perl 5.8, that really means that a lot of people were still using Perl 5.005 so we still needed the warning. I bet most people had moved to Perl 5.6 by the time the fifth edition came out. But, now that it’s 2011, we’re going to assume that life started with Perl 5.8. If people are using something before then, they are out of luck with the new edition.
You can read about signals in the perlipc documentation. Instead of interrupting the program, which might be in the middle of a system call, allocating memory, or something else that needs to finish so things don’t go horribly wrong,
perl lets them finish. For most signals,
perl merely sets a flag and keeps doing what it was doing. When
perl gets to a safe spot, like the space between opcodes, it checks for the signal flags and handles what it finds.
For the pipes, it’s time to move those to the three (or more) argument form of open. Previously we had this example:
open DATE, "date|" or die ...;
With the three-argument
open my $date_fh, '-|', 'date' or die ...;
Note that autodie doesn’t show up until the next chapter, so we still use
And, since we emphasize modules much more in this edition, we added a short introduction to IPC::System::Simple, even though it’s not a core module (yet).