sigint

Can I send SIGINT to a Python subprocess on Windows?

耗尽温柔 提交于 2019-12-10 14:49:21
问题 I've got a Python script managing a gdb process on Windows, and I need to be able to send a SIGINT to the spawned process in order to halt the target process (managed by gdb) It appears that there is only SIGTERM available in Win32, but clearly if I run gdb from the console and Ctrl+C, it thinks it's receiving a SIGINT. Is there a way I can fake this such that the functionality is available on all platforms? (I am using the subprocess module, and python 2.5/2.6) 回答1: Windows doesn't have the

How to gracefully terminate an asyncio script with Ctrl-C?

隐身守侯 提交于 2019-12-09 16:14:14
问题 I've read every post I could find about how to gracefully handle a script with an asyncio event loop getting terminated with Ctrl-C, and I haven't been able to get any of them to work without printing one or more tracebacks as I do so. The answers are pretty much all over the place, and I haven't been able implement any of them into this small script: import asyncio import datetime import functools import signal async def display_date(loop): end_time = loop.time() + 5.0 while True: print

Catching signal inside its own handler

瘦欲@ 提交于 2019-12-09 02:38:10
问题 #include<stdio.h> #include<signal.h> void handler(int signo) { printf("Into handler\n"); while(1); } int main() { struct sigaction act; act.sa_handler = handler; act.sa_flags = 0; sigemptyset(& act.sa_mask); sigaction(SIGINT, &act, NULL); while(1); return 0; } After catching the KeyboardInterrupt once, when I press "Ctrl+C" again, SIGINT is not handled... I intend that "Into handler" should be printed each time I press "Ctrl+C" . I want to catch SIGINT inside the "SIGINT handler()" itself..

sending SIGINT CTRL-C using ganymed SSH2?

≯℡__Kan透↙ 提交于 2019-12-08 07:37:43
问题 I need to kill a process that I have started using ganymed SSH2. Specifically I would like to gracefully kill it using Ctrl + C . I have seen ideas of trying to send ASCII \x03 but when using the execCommand() it wont take escaped chars. How can I send Ctrl + C SIGINT through ganymed? If there is another Java SSH app I should be using let me know, I have looked into Jsch, sshj but just found ganymed ssh2 to the be easiest. The program i am trying to kill is tethereal (wireshark) 回答1: I've

sending SIGINT CTRL-C using ganymed SSH2?

寵の児 提交于 2019-12-07 16:13:26
I need to kill a process that I have started using ganymed SSH2. Specifically I would like to gracefully kill it using Ctrl + C . I have seen ideas of trying to send ASCII \x03 but when using the execCommand() it wont take escaped chars. How can I send Ctrl + C SIGINT through ganymed? If there is another Java SSH app I should be using let me know, I have looked into Jsch, sshj but just found ganymed ssh2 to the be easiest. The program i am trying to kill is tethereal (wireshark) WhiteFang34 I've used this with JSch to successfully send Ctrl + C : JSch jsch = new JSch(); Session session = jsch

Cygwin CTRL-C (Signal Interrupts) not working properly - JVM Shutdown Hooks not starting

陌路散爱 提交于 2019-12-06 17:18:39
问题 I'm working on a Java application that utilises shutdown hooks in order to clean up on termination/interruption of the program, but I've noticed that Cygwin's implementation of CTRL-C doesn't seem to trigger the shutdown hooks. On the surface it appears to have interrupted the process, relinquishing control back to the command line, however the process' shutdown hooks are not triggered at all so cleanup does not occur. In cmd they get caught, but due to various constraints I need to somehow

GLib: Graceful termination of GApplication on Unix SIGINT

五迷三道 提交于 2019-12-06 10:12:29
When the user hits Ctrl + C in a Posix / Linux shell with a program running, that program recieves a SIGINT signal. When running a program based on GApplication, this means that the program gets terminated immediately. How can I overcome this and have GApplication shut down gracefully? You can use g_unix_signal_add() . This function takes a callback that is called once the program recieves the signal you specify. (SIGINT in this case) That callback should then call g_application_release() until the GApplication's use count dropped to zero. Once that is the case, the Main Loop will terminate

How to pass SIGINT to child process with Python subprocess.Popen() using shell = true

会有一股神秘感。 提交于 2019-12-06 09:22:25
问题 I am currently trying to write (Python 2.7.3) kind of a wrapper for GDB, which will allow me to dynamically switch from scripted input to interactive communication with GDB. So far I use self.process = subprocess.Popen(["gdb vuln"], stdin = subprocess.PIPE, shell = True) to start gdb within my script. ( vuln is the binary I want to examine) Since a key feature of gdb is to pause the execution of the attached process and allow the user to inspect registers and memory on receiving SIGINT (STRG

Saving work after a SIGINT

两盒软妹~` 提交于 2019-12-05 14:42:52
I have a program which takes a long time to complete. I would like it to be able to catch SIGINT (ctrl-c) and call the self.save_work() method. As it stands, my signal_hander() does not work since self is not defined by the time the program reaches signal_handler() . How can I set it up so self.save_work gets called after a SIGINT ? #!/usr/bin/env python import signal def signal_handler(signal, frame): self.save_work() # Does not work exit(1) signal.signal(signal.SIGINT, signal_handler) class Main(object): def do_stuff(self): ... def save_work(self): ... def __init__(self): self.do_stuff()

Cygwin CTRL-C (Signal Interrupts) not working properly - JVM Shutdown Hooks not starting

ⅰ亾dé卋堺 提交于 2019-12-04 22:56:37
I'm working on a Java application that utilises shutdown hooks in order to clean up on termination/interruption of the program, but I've noticed that Cygwin's implementation of CTRL-C doesn't seem to trigger the shutdown hooks. On the surface it appears to have interrupted the process, relinquishing control back to the command line, however the process' shutdown hooks are not triggered at all so cleanup does not occur. In cmd they get caught, but due to various constraints I need to somehow get them working in Cygwin. Is there any way to fire a SIGINT at a running process through Cygwin at all