sigint

Ignoring ctrl-c

I'm trying to write a shell and I'm at the point where I want to ignore ctrl-c. I currently have my program ignoring SIGINT and printing a new line when the signal comes, but how can I prevent the ^C from being printed? When pressing ctrl-c, here is what I get: myshell>^C myshell>^C myshell>^C but I want: myshell> myshell> myshell>...

Can I send a ctrl-C (SIGINT) to an application on Windows?

I have (in the past) written cross-platform (Windows/Unix) applications which, when started from the command line, handled a user-typed Ctrl-C combination in the same way (i.e. to terminate the application cleanly). Is it possible on Windows to send a Ctrl-C/SIGINT/equivalent to a process from another (unrelated) process to request that...

Sending SIGINT to a subprocess of python

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 wa...

Stopping the inferior process in GDB WITHOUT a signal?

Is there a way to stop the inferior without using Ctrl+C (or an equivalent signal sent from another process?) I'm using a windows platform and am managing GDB from another process, so with no notion of signals, it seems that there isn't a good way to break execution of my program when it's free running without any breakpoints. EDIT FOR...

How to send SIGINT to a remote process over SSH?

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 be...

How to ask bash to wait for a result and send a SIGKILL when it get it ?

I want to use zbarcam but after reading a barcode, it doesn't stop. $ zbarcam | xvkbd -file - -window emacs EAN-13:6941428130969 CODE-128:3096140900557 Do you know how I can tell bash to kill zbarcam after printing on the stdout the first \n ? ...

How can I catch a ctrl-c event? (C++)

How do I catch a ctrl-c event in C++? ...

Saving work after a SIGINT

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? #...

send SIGINT to child process

I am trying to create a child process and then send SIGINT to the child without terminating the parent. I tried this: pid=fork(); if (!pid) { setpgrp(); cout<<"waiting...\n"; while(1); } else { cout<<"parent"; wait(NULL); } but when I hit C-c both process were terminated ...

SIGINT handling and getline

I wrote this simple program: void sig_ha(int signum) { cout<<"received SIGINT\n"; } int main() { string name; struct sigaction newact, old; newact.sa_handler = sig_ha; sigemptyset(&newact.sa_mask); newact.sa_flags = 0; sigaction(SIGINT,&newact,&old); for (int i=0;i<5;i++) { cout<<"Enter text: "; getline(cin,name)...

C++: Continue execution after SIGINT

Okay, I am writing a program that is doing some pretty heavy analysis and I would like to be able to stop it quickly. I added signal(SIGINT, terminate); to the beginning of main and defined terminate like: void terminate(int param){ cout << endl << endl << "Exit [N]ow, or [A]fter this url?" << endl; std::string answer; cin >> ...

Catching signal inside its own handler

#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 on...

sending control+c (SIGINT) to NSPIPE in objective-c

Hello, I am trying to terminate an openvpn task, spawned via NSTask. My question: Should I send ctrl+c (SIGINT) to the input NSPipe for my NSTask? inputPipe = [NSPipe pipe]; taskInput = [inputPipe fileHandleForWriting]; NSString dataString = @"\cC"; [taskInput writeData:[dataString dataUsingEncoding: [NSString defaultCStringEncoding]...

How to stop SIGINT being passed to subprocess in python?

My python script intercepts the SIGINT signal with the signal process module to prevent premature exit, but this signal is passed to a subprocess that I open with Popen. is there some way to prevent passing this signal to the subprocess so that it also is not exited prematurely when the user presses ctrl-c? ...

Signal passing to managed processes using supervisord

I am using supervisord to spawn and manage a FastCGI application that I am writing in C for a linux target. I have a signal handler that gracefully exits my application when SIGINT is received. I have verified that the signal handler works as desired by running the app in a terminal window and issuing Ctrl-C to exit. When issuing a "sh...

Signal handler, python

I have a multithreaded program and use the signal.signal(SIGINT,func) to kill all threads when ctrl c is pressed. The question I have is this: I have to call signal.signal(...) from main in python. Do I have to call that on a loop or can I just set it once and whenever the user presses ctrl c, the signal will be caught? ...

How can I catch SIGINT in threading python program?

Hello. When using threading module and Thread() class, SIGINT (Ctrl+C in console) could not be catched. Why and what can I do? Simple test program: #!/usr/bin/env python import threading def test(suffix): while True: print "test", suffix def main(): for i in (1, 2, 3, 4, 5): threading.Thread(target=test, ar...