全部博文(1144)
分类: LINUX
2009-12-09 11:56:49
#!/usr/local/bin/perl # to make a disk go nuts use strict; my $dir = '/var'; # director to put a test file my $ttr = 600; # time to run my @children; for(1..3){ my $pid = fork(); if($pid){ # parent push @children, $pid; }elsif($pid == 0){ # child eval { local $SIG{ALRM} = sub { die "finished.\n"; }; alarm($ttr); while(1){ open(ZERO, "/dev/zero") || die "cannot read from zero: $!\n"; my $x; sysread(ZERO, $x, 10240000); close ZERO; open(FILE, ">${dir}/pegio.$$") || die "cannot write to $dir/pegio.$$: $!\n"; print FILE $x; close FILE; } alarm(0); }; unlink("$dir/pegio.$$") || warn "could not unlink $dir/pegio.$$\n"; alarm(0); warn $@ if($@); exit; }else{ die "couldnt fork: $!\n"; } } foreach(@children){ waitpid($_,0); }