Questions tagged [sigint]

On POSIX-compliant platforms, SIGINT is the signal sent to a process by its controlling terminal when a user wishes to interrupt the process.

On POSIX-compliant platforms, SIGINT is the signal sent to a process by its controlling terminal when a user wishes to interrupt the process.

Wikipedia: https://en.wikipedia.org/wiki/SIGINT_%28POSIX%29#SIGINT

369 questions
11
votes
2 answers

How can I handle SIGINT in Erlang?

I know how to create custom signal handlers in Java, Python, Ruby, Perl, and Lisp, thanks to Google and a plethora of tutorials. I can't find online how to create handlers for SIGINT, SIGTERM, HUP, etc. in Erlang.
mcandre
  • 22,868
  • 20
  • 88
  • 147
10
votes
3 answers

How to interrupt Python I/O operations when threading?

For example, with open("foo") as f: f.read() (But it could be a file write, a DNS lookup, any number of other I/O operations.) If I interrupt this program while reading (SIGINT), the I/O operation is halted and KeyboardInterrupt is thrown, and…
Paul Draper
  • 78,542
  • 46
  • 206
  • 285
10
votes
4 answers

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

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 =…
Mike
  • 111
  • 1
  • 1
  • 6
10
votes
2 answers

Why Linux always output "^C" upon pressing of Ctrl+C?

I have been studying signals in Linux. And I've done a test program to capture SIGINT. #include #include #include void signal_handler(int signal_no); int main() { signal(SIGINT, signal_handler); for (int i = 0; i…
WiSaGaN
  • 46,887
  • 10
  • 54
  • 88
9
votes
1 answer

Handle CTRL-C in Python cmd module

I wrote a Python 3.5 application using the cmd module. The last thing I would like to implement is proper handling of the CTRL-C (sigint) signal. I would like it to behave more or less the way Bash does it: print ^C at the point the cursor is clear…
wujek
  • 10,112
  • 12
  • 52
  • 88
9
votes
1 answer

Using rlwrap with Node.js REPL, how could node '.break' (Ctrl-C) not be interpreted as a SIGINT by rlwrap?

Following this discussion on how to preserve command line history between sessions, I defined the following alias: alias node='env NODE_NO_READLINE=1 rlwrap node' It works perfectly for the history persistance but now, everytime I do a Ctrl-C to…
maxlath
  • 1,804
  • 15
  • 24
8
votes
2 answers

Interrupting Python raw_input() in a child thread with ^C/KeyboardInterrupt

In a multithreaded Python program, one thread sometimes asks for console input using the built-in raw_input(). I'd like to be able to be able to close the program while at a raw_input prompt by typing ^C at the shell (i.e., with a SIGINT signal).…
adrian
  • 1,447
  • 15
  • 24
8
votes
1 answer

How to make a python context manager catch a SIGINT or SIGTERM signal

I stream data using context manager to close the connection when the program exits. I run my program as a daemon in the background. How can I make the context manager handle the case when the daemon is interrupted by a SIGINT or SIGTERM or any…
gohu
  • 151
  • 1
  • 9
8
votes
1 answer

catching SIGINT in a multithreaded program

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…
nikos
  • 383
  • 1
  • 5
  • 9
8
votes
2 answers

Prevent Ctrl+C from interrupting exec.Command in Golang

I've noticed that processes started with exec.Command get interrupted even when the interrupt call has been intercepted via signal.Notify. I've done the following example to show the issue: package main import ( "log" "os" "os/exec" …
laurent
  • 88,262
  • 77
  • 290
  • 428
8
votes
2 answers

signal() overwriting other signal handlers

Does the signal() function overwrite other signal calls a process might have set up? I.e. if a SIGINT handler has been setup by a process, and a DLL calls signal(SIGINT,xxx) to handle its own termination code, does the original SIGINT handler get…
Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
7
votes
1 answer

How do I catch *and ignore* SIGINT in Node.js?

I've found a different post on a related topic (How to perform an async operation on exit), but perhaps it doesn't apply to macOS, or just isn't true anymore when running Node.js v14. My original question was more complicated. I couldn't get…
kshetline
  • 12,547
  • 4
  • 37
  • 73
7
votes
1 answer

Why can't I CTRL-C a sleep infinity in docker when it runs as PID 1

Case: we have a docker container that runs a bash script that needs to "block" forever (because it exposes a volume for another container, but there are other reasons why we sometimes want this). I thought this could work then: exec sleep…
Otto
  • 1,787
  • 1
  • 17
  • 25
7
votes
3 answers

Julia, handle keyboard interrupt

Title says it all. How can I handle or catch a SIGINT in julia? From the docs I assumed I just wanted to catch InterruptException using a try/catch block like the following try while true println("go go go") end catch ex …
alto
  • 231
  • 2
  • 7
6
votes
3 answers

Using a SIGINT from Ctrl+C

alright, so i'm using a sighandler to interpret some signal, for this purpose it is Ctrl+C, so when Ctrl+C is typed some action will be taken, and everything is fine and dandy, but what I really need is for this to happen without ^C appearing in the…
1 2
3
24 25