perljunky has asked for the wisdom of the Perl Monks concerning the following question:

I have a need to put the script I am running in background. However as soon as I fork the child is getting the INT signal sent to it and the &INT_handler is kicking in. I am sure I havent coded it correctly. Can you help please?
#!/usr/bin/perl # Put script in background but wait a few before exiting sleep 10, exit if (my $pid = fork); # Signal handling routines $SIG{'INT'} = &INT_handler; $SIG{'QUIT'} = &QUIT_handler; # rest of child code below including sub INT_handler

Replies are listed 'Best First'.
Re: Putting script in background
by Fletch (Bishop) on Sep 13, 2007 at 00:07 UTC

    Hard to tell considering the lack of markup on your code sample, but it would appear you're calling INT_handler and setting $SIG{INT} to it's return value. You want \&INT_handler to return a reference to your sub instead there.

    Update: And there was markup. Huzzah, much better. :)

      d-uh ofcourse. Thank you. So my reputation now goes -1000000 :-) Thanks again