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
3
votes
1 answer

Not able to catch a SIGINT signal while using pthreads

I have made a chat server which uses multi-threading for dealing with multiple clients. I have a while loop which runs infinitely and waits for new clients. I want to come out of it after I press ctrl+c. So, I am trying to catch the SIGINT signal as…
Shivam Mitra
  • 1,040
  • 3
  • 17
  • 33
3
votes
1 answer

Can R interpret a SIGINT/SIGTERM and execute a process as a result?

Is there anyway to capture a SIGINT or SIGTERM from the shell in R so that I can try to execute some graceful exit code? So far, I haven't found anything in my search.
Shuo
  • 491
  • 1
  • 6
  • 16
3
votes
1 answer

Python SIGINT not caught

I don't manage to understand why my SIGINT is never caught by the piece of code below. #!/usr/bin/env python from threading import Thread from time import sleep import signal class MyThread(Thread): def __init__(self): …
myoan
  • 401
  • 5
  • 14
3
votes
1 answer

Not able to catch SIGINT signal while using select()

I'm trying to handle signals while listen socket in syscall select. Problem: I have the working loop with select call. select waits for socket descriptor is ready. There is need to break loop by SIGINT or SIGQUIT and correct close resources and exit…
3
votes
1 answer

Sending control+c (SIGINT) to NSPIPE in objective-C

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 =…
Ron
  • 1,610
  • 15
  • 23
3
votes
1 answer

SIGINT and SIGQUIT

I want to start the calculator application from my code, interrupt it with sigint-2 shows that it has been interrupted, start it again, and then quit it with sigquit-9, the idea is to interrupt it within the C code so it is not necessary to press…
FlipFlopSquid
  • 99
  • 1
  • 4
  • 11
3
votes
1 answer

Catch SIGINT and call a method in an object

I know how to capture SIGINT / SIGTERM signal in Python, but all examples I found are very primitive. I need to call a specified method in an object when SIGINT or SIGTERM occurs, is there any way how to implement this? def sigint_handler(signum,…
Marek Teuchner
  • 327
  • 1
  • 4
  • 15
3
votes
1 answer

Control-C kills Ipython in git bash on Windows 7

After so many years cruising on Linux, I am back on a freaking Windows environment. I use Ipython, and I launch it in git bash. It would be hard for me to use something else, since the environment is configured to use this at my office. So, when I…
3
votes
1 answer

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…
zmbush
  • 2,790
  • 1
  • 17
  • 35
3
votes
0 answers

Why does SIGINT sent to Python script kill MySQL connection?

I'm having an issue with sending SIGINT's to python scripts which are connecting to a MySQL database using MySQLdb (mysql-python). The python script runs in an infinite loop, and I want to catch the SIGINT and gracefully exit after completing the…
3
votes
1 answer

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; …
ThP
  • 2,312
  • 4
  • 19
  • 25
3
votes
2 answers

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

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…
fearless_fool
  • 33,645
  • 23
  • 135
  • 217
3
votes
3 answers

Best pratice to free allocated memory on SIGINT

I have a simple program which uses select and stuff like that for multiplexing IO. To interrupt the "server" process, I integrated a sig_handler which reacts on SIGINT. Each time when memory is allocated, the containing method does the free itself…
CSchulz
  • 10,882
  • 11
  • 60
  • 114
2
votes
0 answers

Why trap works differently with bash than with sh?

I have small script that sets trap and tries to send SIGINT to the child when it receives that signal itself. However, it doesn't seem to work with sh at all, unlike with bash. #!/bin/bash first() { trap 'echo "INT first"' INT sleep 10 …
Afkaaja
  • 47
  • 5
2
votes
2 answers

SIGINT signal()/sigaction in C++

So here is my code: void sigHandle(int sig) { signal(SIGINT, sigHandle); //Is this line necessairy? cout<<"Signal: "<
OmegaTwig
  • 243
  • 1
  • 4
  • 15