I've got a perl script, and i'm attempting to spawn a new thread. The (greatly simplified) flow is as such:
main_file.pl ------------------- use strict; use Env; use Getopt::Long; use Config::Properties; use Net::FTP::Recursive; use Net::SFTP::Foreign; use File::Copy; use File::Basename; use Cwd; use Fcntl ':mode'; use MIME::Base64::Perl; use Net::MySQL; ... if(something){ require("sub_file.pl"); sub_from_sub_file(); } ... sub_file.pl ------------------- use strict; use XML::LibXML; use Config::Properties; use DBI; use threads; ... sub_from_sub_file(){ print "Before\n"; my $thr = threads->new(\&sub1); print "After\n"; } sub sub1{ print "HI!\n"; } ...

output would be: "Before"
Now, if i create a thread directly in the main, it seems to work okay, but calling it in the require()'d file it either 1) waits a moment then fails with "Alarm Clock" 2) or if i add $SIG{ALRM}="IGNORE"; it just waits forever.

For some reason the thread is never being spawned properly, i know this isn't my real code, which i can't really post, but does this issue make sense to anyone? I included all of the modules i'm using in the two scripts, but I'm not sure if that makes a big diff.

In reply to ithreads not behaving as expected by madorb

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.