signals

How to add code to the standard signal handler?

核能气质少年 提交于 2019-12-12 13:18:27
问题 I have a C application running on Linux where I need to add some code to the standard signal handler. The idea was to setup my handler saving the pointer to the standard one and call the saved handler from my code. Unfortunately, neither signal() nor sigaction() return pointer to the standard handler. Both of them return NULL instead. Is there any way of doing custom handling and continuing with the standard handling without removal of the custom handler and sending the same signal again? 回答1

What cause info can be readily collected in an iOS signal handler?

时间秒杀一切 提交于 2019-12-12 12:32:56
问题 I'm trying to add some crash logging to an app, and I have a signal handler set up to catch the standard "fatal" signals. What "cause" information (if any) can I practically/simply collect in the signal handler for logging? (I've spent about 2 hours Googling stuff, but most of what i find is for other environments and is too complex to be reliable. I'm looking for what's simple to do, specifically in an iOS environment.) (I already have an Objective-C exception handler to catch Objective-C

CTRL+C and CTRL+Break are different?

耗尽温柔 提交于 2019-12-12 12:17:48
问题 I've thought they are definitly same. But I just found some values CTRL_C_EVENT and CTRL_BREAK_EVENT at SetConsoleCtrlhandler function. Is there a difference? 回答1: See the official documentation here: CTRL+C and CTRL+BREAK Signals I quote: CTRL + BREAK is always treated as a signal, but an application can change the default CTRL + C behavior in two ways that prevent the handler functions from being called 来源: https://stackoverflow.com/questions/5056567/ctrlc-and-ctrlbreak-are-different

Displaying or redirecting a shell's job control messages

主宰稳场 提交于 2019-12-12 11:11:38
问题 TL;DR All job control / crash messages are hidden when they occur within a function. I go into more detail below, but @Barmar has pointed out that this issue can be reproduced by running a crashing binary inside of a function, e.g: crun() { /tmp/faulty $1 $2 $3 } I've defined a function in my .zshrc to compile & run source code with the function below: crun() { local file=$1 shift local exepath="$(mktemp)" if [[ $file =~ "\.c$" ]]; then gcc -g -Wall $file -o $exepath || return $? else echo

Signal Stack

馋奶兔 提交于 2019-12-12 11:03:40
问题 I did read that signals need to have a separate stack, why and how do you think it is implemented ? Are they dynamically allocated or statically allocated ? How is memory allocation done ? Is it the same for all signals ? 回答1: The reason that signals need a separate stack is that, if the normal stack gets corrupted or overflows, the signal can still execute. I think the signal stack is usually allocated dynamically, but it could implemented be either way. You can set a new signal stack with

Python GTK signal handler not working

隐身守侯 提交于 2019-12-12 11:02:19
问题 I am writing a Python application using GTK for the GUI. I noticed that closing it with Ctrl-C from the terminal isn't working and I discovered this is because of a bug, so I tried to manually handle the signal. The problem is that if I set the default behaviour to the default one, the signal is caught and the application is closed correctly, but if I use a custom handler it doesn't work. Here is my (simplified) code: from gi.repository import Gtk import signal class MainWindow(Gtk.Window):

compile errors using signal.h in Linux [duplicate]

痴心易碎 提交于 2019-12-12 09:31:26
问题 This question already has answers here : struct sigaction incomplete error (2 answers) Closed 5 years ago . I'm writing a shell program that must handle signals. My relevant signal handling related code is as follows: #include <signal.h> ... #include <sys/types.h> ... void installSigactions( int, struct sigaction* ); void handler_function( int signal_id ); ... /*define signal table*/ struct sigaction signal_action; /*insert handler function*/ signal_action.sa_handler = handler_function; /

send signal between scripts (bash)

做~自己de王妃 提交于 2019-12-12 09:19:52
问题 I've a little problem, probably it's a stupid question, but I started learning bash about a week ago... I have 2 script, a.sh and b.sh. I need to make both running constantly. b.sh should waits for a signal from a.sh (I'm trying to explain: a.sh and b.sh run --> a.sh sends a signal to b.sh -> b.sh traps signal, does something --> a.sh does something else and then sends another signal --> b.sh traps signal, does something --> etc.) This is what I've tried: a.sh: #!/bin/bash ./b.sh &; bpid=$!;

Is there a C++ cross platform “named event like the ”CreateEvent()" in Win32?

梦想的初衷 提交于 2019-12-12 08:05:30
问题 I am looking for something analogous to CreateEvent(), SetEvent() and WaitForMultipleObjects() from the Win32 world. Specifically this has to be accessible across processes on the same machine. We are already using Poco for some cross platform stuff, but I don't see that the Poco::Event is what I want. perhaps i am missing something. EDIT: To explain what I want to do: I want process B to know when something happens in process A. This is trivial in win32 - Each process/thread calls

How to use templates with QT signals and slots?

こ雲淡風輕ζ 提交于 2019-12-12 07:57:42
问题 I want to use signals and slots in my program, but unfortunately they should be used for transmitting several different data types (e.g. QString, double, etc.) and I don't want to write twenty different slots just because I need one for each data type. But when I want to declare a slot like template <typename t> void Slot1(t data); QT tells me that it is not possible to use templates in signals and slots. Is there a workaround? Or can my approach simply improved? 回答1: Accurate answer: It is