[Pdx-pm] forking
Michael Rasmussen
mikeraz at patch.com
Thu Jan 25 05:08:54 PST 2007
Michael G Schwern wrote:
> Michael Rasmussen wrote:
> > Consider this code representation:
> >
> > while( database_query ) {
> >
> > bunch of stuff
> >
> > if(my $pid = fork) {
> > parent processing
> > } else { # child stuff follows
> > if( ! $test_target ) {
> > print "WTF? No $test_target?\n";
> > $ret = test_it($test_target);
> > exit $ret;
> > }
> > }
> > }
> >
> > At this point you may be chuckling, scratching your head, wiping beverages off the
> > monitor or ...
>
> Or having no idea. I give, what's the gag?
I thought you were kidding. I was almost embarrassed to post it...
A re-write:
while( database_query ) {
bunch of stuff
if(my $pid = fork) {
parent processing # so far so good
} else { # child stuff follows
if(! $test_target) {
print "WTF? No $test_target?\n"; # should have a $test_target, something is wrong here
$ret = test_it($test_target); # no target? are you sure a test is a sane thing to do?
exit $ret; # give a result and quit being childish
}
# flow here if we have a target to test
} # how special, the child program flow now joins with the parent, real family togetherness
} # loop up for another db query, parent activities, another fork ...
When I ran it the
first clue was DBI errors about attempts to write to a locked db, and I only write in two parent places
second clue was the system load averages staying very low, .05, but the system became unresponsive
third clue was I/O wait shot up to 90%+, while all other sysload items stayed low, including swap
fourth clue was "ps -ef | grep perl | perl -nae 'print $F[1],$/;' | xargs -n 1 kill -9"
(Solaris system) would kill lots of processes and at the end I'd have lots still running.
fifth clue was it worked fine a few days ago, so I must have done something...
I believe this is called a fork bomb.
--
Michael Rasmussen, Portland Oregon
Be appropriate && Follow your curiosity
http://www.patch.com/words/
The fortune cookie says:
Satire is tragedy plus time.
-- Lenny Bruce
More information about the Pdx-pm-list
mailing list