#! /usr/bin/perl use threads; print "Starting Fork...\n"; print "Might as well cleanup first...\n"; print "Ending All Python...\n"; system("killall python"); print "--> Cleaning System\n"; system("rm -Rf 100*"); sleep(1); print "Making sure system is ok...\n"; system("mkdir ./in_use ./use ./finished ./finished_already ./finished_ +downloading ./already_done ./acc"); system("chmod 777 ./in_use ./use ./finished ./finished_already ./finis +hed_downloading ./already_done ./acc"); print "\nFinished Cleaning... Startup! \n"; sleep(1); $thr1 = threads->new(\&manager); while (1){sleep(1);} sub initiator(){ print "Found (@_)\n"; my @in_items = @_; print "System...\n"; system("perl silly_fork_handler.pl @_"); print "System Ended!\n"; } sub nothing(){ } sub manager(){ $|++; while(1){ print "."; opendir(DIR,"./acc"); @list = readdir(DIR); close(DIR); foreach (@list){ if ($_ =~ ".dat"){ @new_list[$q] = $_; $q++; +}} #print @new_list; foreach (@new_list){ open(READER,"./acc/$_"); @items = <READER>; close(READER); #print @items; chomp($_); @list5 = $_; $thr = threads->new(\&initiator, @list5); $thr = threads->detach; $line = $_; chomp($line); #cp("./acc/$line","./$line/FORKED.dat"); } opendir(DIR,"./finished"); @list2 = readdir(DIR); close(DIR); foreach (@list2){ $line = $_; chomp($line); if (($line ne ".") && ($line ne "..")){ $output = `tail -n 1 ./$line/WATCH.dat`; chomp($output); if ($output =~ "ERROR:"){system("cp ./$line/WATCH.dat ./tm +p.dat");} unless ($line eq ""){ system ("rm -rf ./$line"); system ("rm -rf ./finished/$line"); } if ($output =~ "ERROR:"){mkdir("./$line"); system("cp ./tm +p.dat ./$line/WATCH.dat");} print "\nRemoved buffered torrent ($line)\n"; } } undef @list; undef @new_list; undef @list2; undef @items; undef $line; $q = 0; sleep(2); } }
In reply to Completely Random Stall by expresspotato
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |