Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Force 2 'ctrl-c's to kill program

by albob (Sexton)
on Feb 11, 2013 at 17:23 UTC ( #1018194=note: print w/replies, xml ) Need Help??


in reply to Re: Force 2 'ctrl-c's to kill program
in thread Force 2 'ctrl-c's to kill program

Cheers. I tried someting like that but again it appears that while I am inside my 1st control_c_observed subroutine, the 2nd Ctrl-C only gets serviced after the routine has finished. That is, it does not appear to allow the 2nd ctrl-c affect the sub-routine called by the 1st Ctrl-C. Now, it could be that I implemented it incorrectly!
  • Comment on Re^2: Force 2 'ctrl-c's to kill program

Replies are listed 'Best First'.
Re^3: Force 2 'ctrl-c's to kill program
by jethro (Monsignor) on Feb 11, 2013 at 18:13 UTC

    So you didn't eliminate the sleep() call? Think about it, why would you still need the sleep call when you know the time the first ctrl-c happened. Without the sleep call the ctrl-c subroutine should be finished almost immediately.

    PS: Using something like sleep() in an interrupt routine is bad design. Interrupt routines should never have a long running time because the code they are interrupting might have expectations of things occuring at a certain speed without seconds-long freezing. For example the user interface

      I understand what you were originally proposing now (along the lines of BrowserUK's code below I assume). Thanks for the advice on sleep. I definitely should take more core in using it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018194]
help
Chatterbox?
[Lady_Aleena]: james28909, bare name...
[james28909]: /msg username message did it
[LanX]: James not /msg [beech] but /msg beech
[james28909]: i havent used the /msg [username] message</c> format
[LanX]: you can also click on beech and message him. ..
[james28909]: jebus
[LanX]: sorry again not [msg://beech]

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2017-05-24 22:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?