$ cat swaphogger.pl #!/usr/bin/perl -w use strict; sub start_hogging_memory { my @blackhole; my $count = 0; print __FILE__ . " [" . __LINE__ . "] child [$$]\n"; open ( FH, "> ${0}_${$}.output" ) or die " could not open file:$!\n"; my $swapon = `swapon -s | tail -1`; while ( 1 ) { chomp( $swapon ); print FH "[$swapon $count]\n"; push @blackhole, "$count -----------------------------------------------------------------------\n"; $count++; $swapon = `swapon -s | tail -1` # strangeness } close (FH); } my $maxChildren = shift; my $numChildren = 0; while ( $numChildren < $maxChildren ) { $numChildren++; my $pid = fork(); if ( $pid == 0 ) { start_hogging_memory (); } elsif ( $pid ) { print __FILE__ . " [" . __LINE__ . "] parent [$$]\n"; } else { die __FILE__ . " [" . __LINE__ . "] couldn't fork() :$!\n"; } }