in reply to Re: Interrupt Handling - What am I doing wrong?
in thread Interrupt Handling - What am I doing wrong?

Nope..buffering is not the issue .... I had the $| = 1 set; just forgot to paste it in the code above.

Is the behaviour of the code due to "sleep", i.e., am telling my program to sleep and not do anything else...so, its not doing anything else (like printing the stuff it's supposed to)...? If so, is there something I can use to simulate a long running process (that runs for about 2-3 mins)?

I'm out of ideas for this one.. been trying all morning without luck!

  • Comment on Re^2: Interrupt Handling - What am I doing wrong?

Replies are listed 'Best First'.
Re^3: Interrupt Handling - What am I doing wrong?
by ikegami (Patriarch) on Apr 20, 2011 at 18:05 UTC

    Do you really not get "Waiting for critical tasks to finish before terminating program"? That would mean your signal handler isn't called at all.

    Either way, I already gave a reason the current code won't always work. Executing the signal handler will prevent (at least) that thread from doing anything else. If the signal handler is called from a thread1 thread, that thread1 thread won't be able to progress.

      Oh.. I do get the message. Its just that it's not being displayed right away..as soon as I press Ctrl C. The message is suppressed till the thread completes the "join". As soon as it joins, the message is displayed. Somehow, the join is blocking - not sure why.

      If I remove threads, and just use the normal expect.pm module..spawn a remote session ... do my work and press Ctrl C....the message appears immediately. What is it in the threads that is causing this behaviour?

        Signals are only checked between Perl ops.