in reply to INT signal kills process run with expect, when $SIG{'INT'} is set

It's actually kills even w/o Expect. Code below is killed with ^c too:
require Expect; use strict; $SIG{'INT'}=sub {print "Al Bundy rules!\n";}; sleep 10000;
The prcess lasts until 1st ^c.
  • Comment on Re: INT signal kills process run with expect, when $SIG{'INT'} is set
  • Download Code

Replies are listed 'Best First'.
Re^2: INT signal kills process run with expect, when $SIG{'INT'} is set
by cdarke (Prior) on Feb 22, 2011 at 09:05 UTC
    On many platforms sleep will exit on any signal, including SIGINT. You need to place it in a loop. For example:
    use warnings; use strict; $SIG{'INT'}=sub {print "Clive Darke rules!\n";}; while (1) { sleep 10000; }
Re: INT signal kills process run with expect, when $SIG{'INT'} is set
by ikegami (Patriarch) on Feb 22, 2011 at 16:53 UTC

    It doesn't kill the process, handled signals interrupt sleep. If they didn't, the handler wouldn't get to run. See Re: fork() doesn't care about my sleep()? for how to make sleep uninterruptible.

    The OP didn't (visibly) use a sleep in the process that has a signal handler, so this isn't (likely to be) the OP's problem.