Questions tagged [signal-handling]

In the C Standard Library, signal processing defines how a program handles various signals while it executes. A signal can report some exceptional behavior within the program (such as division by zero), or a signal can report some asynchronous event outside the program (such as someone striking an interactive attention key on a keyboard).

290 questions
1
vote
0 answers

Using Ctrl+Z to background a process in a C Shell

I am trying to implement the behaviour of Ctrl+Z in a mini C Shell. My code currently receives the SIGTSTP signal and correctly suspends the process, however I can't seem to get it to move to the background and put the shell process back in the…
Goulash
  • 3,708
  • 6
  • 29
  • 48
1
vote
1 answer

Ctrl+c kills process, despite signal handling, works on different machine

I am running a C++ application on xubuntu and implemented a signal handler which handles SIGINT. My implementation should be fine, since it is working on all other machines (same OS) - except mine. "Working" means that the signal is received by a…
spmmfycn
  • 21
  • 3
1
vote
1 answer

Blocking signals causes boost process not to work

In the code below the class Process can run a process using boost process in asynchronous mode and can kill it if it times out. Now in order to shut it down, I block all the signals in all threads and create a specific thread signal_thread to handle…
bisarch
  • 1,388
  • 15
  • 31
1
vote
2 answers

How to only kill the child process in the foreground?

I am trying to build a shell, and I've managed to code most of the functionality in, however I have a small problem. Say I type firefox &. Firefox will open up as a background process. The & activates a BG flag that makes the parent not wait for the…
ENBYSS
  • 819
  • 1
  • 10
  • 22
1
vote
4 answers

Create temp dir that is globally known and that gets automagically removed (C++)?

In C++, I have a few functions that need to write to a temp directory. Ideally, only one temp directory gets created that they all write to (to minimize I/O overhead). That directory should be automagically removed when the program exits. However, I…
Markus
1
vote
0 answers

Handler for SIGCHLD signals

The code doesn't work and it goes in loop. I think the error is in the gestore method, that is a handler for SIGCHLD signals. This is the first time I use a handler to capture SIGCHLD signals. This program continue to casually extracts from 0 to…
user9062823
1
vote
1 answer

Handling SIGQUIT with sigwait

I'm writing a multithreaded program which needs to be terminated with the following bash line: killall -QUIT -w procname I decided to use a thread to receive some signals I need to handle, like SIGQUIT and SIGUSR1, and to ignore SIGQUIT in the…
Gixuna
  • 86
  • 8
1
vote
1 answer

QML connect signal from the main component to the child components

I have a Qt application that calls qt_update_values() to the main QML component. I want to send the new values to a specific delegate. How do I connect update_values() from the main component to be received by a specific child component, which is…
laurapons
  • 971
  • 13
  • 32
1
vote
1 answer

Portability of sigaction and sigset_t between Solaris and Linux

I have some legacy code on Solaris platform and I would like to port that to Linux, but I am getting some compilation error on Linux. On Solaris, I have the following code snippet: #include ... void f() { struct sigaction a; …
Dr. Debasish Jana
  • 6,980
  • 4
  • 30
  • 69
1
vote
2 answers

Signal handling error

When I use my_handler as function there is not error but I can't because I have to use another method there. If I build code below : error: invalid use of member functi on (did you forget the ‘()’ ?) This is my first program in C++ void…
Bando
  • 85
  • 1
  • 6
1
vote
1 answer

Can you explain the following signal handling behavior in python?

I have the following program: import socket import sys import threading import signal class serve(threading.Thread): def __init__(self): super(serve, self).__init__() self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) …
amit
  • 10,612
  • 11
  • 61
  • 60
1
vote
1 answer

Can I install a signal handler for Boost unit tests?

I've got a lot of Boost unit tests. I can't find the place where I should put my signal handler. There's no main() function in the files in unit tests directory. It seems that main() is hidden in some macros. In unit_test.hpp I see: namespace boost…
JimmyY
  • 11
  • 3
1
vote
0 answers

How to stop a thread by sending a signal

Suppose a thread is running some code: // thread while (_running) // (1) { rv = read(...); // (2) // do something with data } We can add a signal handler to stop the thread: // signal handler _running =…
Tom Deseyn
  • 1,735
  • 3
  • 17
  • 29
1
vote
1 answer

Handling SIGINT in JuliaLang

Is it possible to catch a SIGINT to stop a Julia program from running, but doing so in an "orderly" fashion? function many_calc(number) terminated_by_sigint = false a = rand(number) where_are_we = 0 for i in eachindex(a) …
pkofod
  • 764
  • 7
  • 18
1
vote
1 answer

How to find the source code of the default signal handler function?

I wanted to see the source code of the default handler of SIGABRT in Linux C, But I couldn't find it. Would you please mind help to find it?