How Perl Saved Planet Earth

D

dave

The year is 2525. Anyone who even utters the word "evolution" is
immediately annihilated. Object oriented programming is owned by the
huge conglomerate Microsoft-Fox-Bush-Bin-laden.

Most "computers" are always on, but the radical underground have fitted
some with "off" buttons and there has been a wild rumor circulating
that someone has created an "interface" to a computer that allows a
certain amount of control over sequencing.

You don't find out until much later that people at the conglomerate
have not only known about these "interfaces" but other things as well.

You don't have time right now to explain how it is you wound up a
stowaway aboard an intergalactic conglomerate mining vessel and learned
of the Perl programming language by eavesdropping on the crew, but
after numerous stops on various planets, a horrible reality sets in.

As near as you can surmise, once "warp drive" became practical, the
conglomerate suddenly began to lower their prices of consumer goods
that obviously have been created in other galaxies on planets such as
these. Originally the whole concept of warp was very controversial
because scientists realized the dangerous paradoxes created by
excursions into the past and was only allowed if a space ship returned
after it departed (relative to conditions at departure).

This did not stop the conglomerate from sending "seed" ships into the
past (and out of the source tree) and returning at certain intervals to
make "harvests" and deal with local problems. (Usually by creating
"reality" using Fox news.)

You decided to remain behind on one of these planets to alert the
inhabitants to the fact that when the expiration date occurs, all the
planet's content will be harvested, and there will be no survivors.

You have learned enough about physics to realize that all the
technological answers currently exist on this planet so you set about
establishing communications between concerned scientists.

Having done so, you now become concerned with "over-population" and you
look in your Perl Cookbook to see what you can do about the problem.

Although your English is a bit rusty and some of the terms seem a bit
quaint, you start finding some programs that just might work.

Considering your initial impression of the educational system creating
"Zombies", that is where you start your search.

Good Fortune! On page 660 of the Perl Cookbook, you find the amazingly
simple solution to your problem under the heading, "16.19 Avoiding
Zombie Processes", where it says:

Problem: Your program forks children, but the dead children accumulate,
fill up your process table, and aggravate your system administrator.

Solution: If you don't need to record the children that have
terminated, use: $SIG{CHLD} = 'IGNORE';

To keep better track of deceased children, install a SIGCHLD handler to
call waitpid:

use POSIX ":sys_wait_h";

$SIG{CHLD} = \&REAPER;
sub REAPER {
my $stiff;
while (($stiff = waitpid(-1, WNOHANG)) > 0) {
# do something with $stiff if you want
}
SIG{CHLD} = \&REAPER; # install *after* calling waitpid
}

After considerable scrutiny, you determine that the children have been
forking mothers and fathers and that it is the mother forkers that are
the real problem because they are the actual cause of the forked up
children.

You are currently engaged in writing a CPAN module to contend with all
these mother forkers.

May the forks be with you...
 
J

John W. Kennedy

The year is 2525. Anyone who even utters the word "evolution" is
immediately annihilated.

Must be rough on drillmasters and choreographers....

---
John W. Kennedy
"Those in the seat of power oft forget their failings and seek only the
obeisance of others! Thus is bad government born! Hold in your heart
that you and the people are one, human beings all, and good government
shall arise of its own accord! Such is the path of virtue!"
-- Kazuo Koike. "Lone Wolf and Cub: Thirteen Strings" (tr. Dana Lewis)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top