sigint

How do I configure ruby to enter the debugger on Ctrl-C (SIGINT)?

青春壹個敷衍的年華 提交于 2019-11-28 14:06:16
I'd like to enter the debugger upon typing ctrl-C (or sending a SIGINT). I have installed the debugger (I'm running Ruby 1.9.3) and verified that it works. I've added this to my setup files (this is for Padrino, but I assume it would be similar for Rails): # file: config/boot.rb Padrino.before_load do trap("SIGINT") { debugger } if Padrino.env == :development end ... but typing Ctrl-C does not invoke the debugger. In fact, if I replace debugger with puts "saw an interrupt!" , typing Ctrl-C doesn't cause a print to happen either. update Following this suggestion from Mike Dunlavey , I tried

How to send SIGINT to a remote process over SSH?

半世苍凉 提交于 2019-11-28 09:10:09
I have a program running on a remote machine which expects to receive SIGINT from the parent. That program needs to receive that signal to function correctly. Unfortunately, if I run that process remotely over SSH and send SIGINT, the ssh process itself traps and interrupts rather than forwarding the signal. Here's an example of this behavior using GDB: Running locally: $ gdb GNU gdb 6.3.50-20050815 (Apple version gdb-1344) (Fri Jul 3 01:19:56 UTC 2009) ... This GDB was configured as "x86_64-apple-darwin". ^C (gdb) Quit ^C (gdb) Quit ^C (gdb) Quit Running remotely: $ ssh foo.bar.com gdb GNU

What is the difference between Ctrl-C and SIGINT?

混江龙づ霸主 提交于 2019-11-28 06:20:24
I have been debugging a Python program which segfaults after receiving a KeyboardInterrupt exception. This is normally done by pressing Ctrl+C from the shell. To test if a particular code change fixed the bug, I had a small shell-script that sent SIGINT to the program at random time after start-up. The problem I have is that sending Ctrl+C seems to have a different effect on the program than sending the signal SIGINT and is thus not causing the bug to appear, so I quite wonder what the difference is then between the two actions. The program does not catch any keyboard actions at all, and is

What happens to a SIGINT (^C) when sent to a perl script containing children?

六月ゝ 毕业季﹏ 提交于 2019-11-27 23:36:45
I have a Perl script that forks. Each fork runs an external program, parses the output, and converts the output to a Storable file. The Storable files are then read in by the parent and the total data from each of the children are analyzed before proceeding onto a repeat of the previous fork or else the parent stops. What exactly happens when I issue a ^C while some of the children are still running the external program? The parent perl script was called in the foreground and, I presume, remained in the foreground despite the forking. Is the SIGINT passed to all children, that is, the parent,

catching SIGINT in a multithreaded program

旧巷老猫 提交于 2019-11-27 16:52:04
问题 I am writing a multithreaded program where I want to handle a possible Ctrl-C command from the user to terminate execution. As far as I know there is no guarantee that the main thread, which is able to cancel every working thread, will catch the signal. Is it, therefore, necessary to have a different signal handler to the code of the working thread so that anyone will catch the signal if it arrives, or is there another way to do that with having a signal handler only in the main thread's code

Capturing SIGINT using KeyboardInterrupt exception works in terminal, not in script

假如想象 提交于 2019-11-27 14:50:55
问题 I'm trying to catch SIGINT (or keyboard interrupt) in Python 2.7 program. This is how my Python test script test looks: #!/usr/bin/python import time try: time.sleep(100) except KeyboardInterrupt: pass except: print "error" Next I have a shell script test.sh : ./test & pid=$! sleep 1 kill -s 2 $pid When I run the script with bash, or sh, or something bash test.sh , the Python process test stays running and is not killable with SIGINT . Whereas when I copy test.sh command and paste it into

How do I configure ruby to enter the debugger on Ctrl-C (SIGINT)?

时间秒杀一切 提交于 2019-11-27 08:09:31
问题 I'd like to enter the debugger upon typing ctrl-C (or sending a SIGINT). I have installed the debugger (I'm running Ruby 1.9.3) and verified that it works. I've added this to my setup files (this is for Padrino, but I assume it would be similar for Rails): # file: config/boot.rb Padrino.before_load do trap("SIGINT") { debugger } if Padrino.env == :development end ... but typing Ctrl-C does not invoke the debugger. In fact, if I replace debugger with puts "saw an interrupt!" , typing Ctrl-C

Is destructor called if SIGINT or SIGSTP issued?

坚强是说给别人听的谎言 提交于 2019-11-27 06:44:48
I have a class with a user-defined destructor. If the class was instantiated initially, and then SIGINT is issued (using CTRL+C in unix) while the program is running, will the destructor be called? What is the behaviour for SIGSTP (CTRL + Z in unix)? No, by default, most signals cause an immediate, abnormal exit of your program. However, you can easily change the default behavior for most signals. This code shows how to make a signal exit your program normally, including calling all the usual destructors: #include <iostream> #include <signal.h> #include <unistd.h> #include <cstring> #include

Python: Catch Ctrl-C command. Prompt “really want to quit (y/n)”, resume execution if no

我怕爱的太早我们不能终老 提交于 2019-11-27 04:02:46
I have a program that may have a lengthy execution. In the main module I have the following: import signal def run_program() ...time consuming execution... def Exit_gracefully(signal, frame): ... log exiting information ... ... close any open files ... sys.exit(0) if __name__ == '__main__': signal.signal(signal.SIGINT, Exit_gracefully) run_program() This works fine, but I'd like the possibility to pause execution upon catching SIGINT, prompting the user if they would really like to quit, and resuming where I left off in run_program() if they decide they don't want to quit. The only way I can

How to send SIGINT to a remote process over SSH?

青春壹個敷衍的年華 提交于 2019-11-27 02:47:16
问题 I have a program running on a remote machine which expects to receive SIGINT from the parent. That program needs to receive that signal to function correctly. Unfortunately, if I run that process remotely over SSH and send SIGINT, the ssh process itself traps and interrupts rather than forwarding the signal. Here's an example of this behavior using GDB: Running locally: $ gdb GNU gdb 6.3.50-20050815 (Apple version gdb-1344) (Fri Jul 3 01:19:56 UTC 2009) ... This GDB was configured as "x86_64