in reply to Re^3: Invalid value for shared scalar
in thread Invalid value for shared scalar

Thanks so much. This is working great, with one problem. The ^C doesn't seem to be working. It kills the programs and errors with "Signal SIGINT received, but no signal handler set." Should I be importing some other module, or registering it a different way? Thanks
$SIG{INT} = sub { print "got a signal\n"; ## Empty the work queue $Qdownload->dequeue while $Qdownload->pending; ## And stack an undef for each fetcher to abort their main loops $Qdownload->enqueue( (undef) x @downloaders ); $stop = 1; };

Replies are listed 'Best First'.
Re^5: Invalid value for shared scalar
by BrowserUk (Patriarch) on Jan 31, 2006 at 19:39 UTC

    Hm. All I can tell you is that it works for me on my system.

    c:\Perl\test>t-spider.pl http://perlmonks.com/index.pl Fetched: 0 (in Q: 0) Fetched http://perlmonks.com/index.pl 1: Stacked 195 links Fetched: 59 (in Q: 121) Fetched http://oreilly.com/promos/perlbooks/?CMP=OTC-FN3412256845 1: Stacked 19 links Fetched http://perl-oak.sf.net 2: Stacked 5 links Fetched: 64 (in Q: 139) Fetched http://cvs.sourceforge.net/viewcvs.py/perl-oak/Oak/liboak2-per +l/lib/Oak2/ 1: Stacked 43 links Fetched: 137 (in Q: 74) Fetched http://www.cafepress.com/perlmonks,perlmonks_too,pm_more 1: Stacked 76 links Fetched: 141 (in Q: 2) Fetched http://everydevel.com 1: Stacked 104 links Fetched http://search.cpan.org/perldoc?DBI#fetchall_arrayref 2: Stacked 459 links Attempted: 143 Status: 200 ( 7 ) Status: 400 ( 136 )

    If you are on Win32, post the output from Perl -V and I'll see if I can isolate the difference.

    If you are on some flavour of *nix, then maybe ^C doesn't generate a SIGINT? You'll have to talk to someone with knowledge of your platform to resolve this issue.

    I should add that using an interupt handler this way is not really an "architected" solution, just a simple mechanism that allowed me to produce a reasonably clean demonstration without getting into the nitty gritty of a full fledged application.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      fair enough. Its just a standard debian install. I will do further research. Thanks so much for all the help.

        One further thought. Id the problem occuring in the code I posted, or in a modification or adaption of it?

        To my knowledge, signal handlers will only work in the main thread, not in a subthread. If you have moved the signal handler into a subthread, that might explain the difference?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.