Hello, So I'm running a perl script that actively scans a directory, checks for a small flat file, imports its items, then runs a separate perl process using a thread then a system call. For some reason, and one point or another it completely locks up. No error messages, no output, nothing. Just seemingly doesn't continue with its usual "..." manager. Is there a limit to the number of active threads? Or a limit on how many perls can be running at once? Some threads run for hours, while some for mere minutes. All in all it seems to work well, for an hour or two that is. Any help would be appreciated my Monks! The code's attached too.

#! /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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.