signals

Graceful termination of Qt application by unix signal

我与影子孤独终老i 提交于 2019-12-10 15:12:24
问题 I have problems saving settings in my application. This is done in the destructors of the relevant objects. It is a launcher and a termination by shutdown is a standard case. The only way the application actually saves the setting is by manual closing it or session shutdown (on cinnamon at least, I guess this just closes all windows). Even sudo reboot prevents the Qt application from unwinding the objects on the stack. Terminating by killall -s <signal> <app> has the same effect for SIGINT ,

How to send signal from kernel to user space

社会主义新天地 提交于 2019-12-10 15:06:48
问题 This question was migrated from Unix & Linux Stack Exchange because it can be answered on Stack Overflow. Migrated 4 years ago . My kernel module code needs to send signal [def.] to a user land program, to transfer its execution to registered signal handler. I know how to send signal between two user land processes, but I can not find any example online regarding the said task. To be specific, my intended task might require an interface like below (once error != 1, code line int a=10 should

Elm - producing a list of random number changing with time

跟風遠走 提交于 2019-12-10 14:58:29
问题 I am trying to make a column of random numbers changing every second, but I get different error messages: import Random main = flow down [ asText (Random.range 0 100 (every second)) , asText (Random.range 0 100 (every second)) ] gives a parse error. What is wrong with my square bracket [ ? Parse error at (line 5, column 1): unexpected '[' expecting newline, spaces or end of input Indent Maybe? Once I indent, the example does compile but I just get <signal> instead of the actual number main =

macOS `sigaction()` handler with `SA_SIGINFO` does not include `si_pid`

穿精又带淫゛_ 提交于 2019-12-10 14:05:12
问题 I'm trying to write a signal handler which needs to know the pid of the process that sends the signal. I'm having no luck with getting anything useful from the siginfo_t passed into my handler on macOS 10.14 with Xcode 10. I've reduced my code to the below minimal sample to demonstrate the issue. In this sample I spawn a child process to send the signal I want to test which is defaulted to SIGTERM , but no other signal I've tried works any better. Assuming you want to build and test this on a

Program terminating on receiving - signal SIG34, Real-time event 34

ⅰ亾dé卋堺 提交于 2019-12-10 13:56:42
问题 In my application the main function calls a funciton - f2 which spawns several threads and application works fine. Now I am trying to add a new function f1 before f2 to spawn a new thread. This new thread prints something on the screen and goes for a sleep in a while loop. I am getting the print once and after some time the application terminates. On debugging the same from GDB I got the following message: (gdb) Program received signal SIG34, Real-time event 34.Quit (gdb) bt #0 0x0fa97cc8 in

why Qt signals' arguments can't be defined with typedef types?

拜拜、爱过 提交于 2019-12-10 13:46:41
问题 For a Qt5/c++11 project, I'm using a QMediaPlayer object (named audio_player) with its positionChanged() signal: This piece of code is ok: connect(this->audio_player, SIGNAL(positionChanged(qint64)), this, SLOT(audio_position_changed(qint64))); But this one doesn't work: typedef PosInAudio qint64; connect(this->audio_player, SIGNAL(positionChanged(PosInAudio)), this, SLOT(audio_position_changed(PosInAudio))); At run-time I get the message "QObject::connect: No such signal QMediaPlayer:

Emulate pthread_kill with C++ threads

点点圈 提交于 2019-12-10 13:45:04
问题 How can I go about emulating the pthread_kill() function with C++ threads? I asked a question about this earlier but there was no response to it. Will the thread::native_handle() function help here? 回答1: So the answer to this question is to rely on platform dependent features and use std::thread::native_handle with pthread_kill() 来源: https://stackoverflow.com/questions/33807645/emulate-pthread-kill-with-c-threads

Handling unix signals in Android

痴心易碎 提交于 2019-12-10 13:26:05
问题 I am writing a Java application that talks to a C++ application using named pipes. When the C++ application dies, the Java gets SIGPIPE and the Java application dies. On C/C++ I know how to catch that signal and ignore it. Is it possible to do something similar on Android/Java? 回答1: It seems this is not really possible. The best solution available would be to add a shut down hook and "gracefully" restart the application, as described here: EDIT: I needed this because (back then) I had JNI

Application never receives RSSI_CHANGED_ACTION

早过忘川 提交于 2019-12-10 13:09:21
问题 I am new to Android programming and am trying to understand the concept of BroadcastReceivers. In order to help myself, I am just trying to write a small application that monitors Wifi signal strength. Now, from my understanding I can simply wait to receive the RSSI_CHANGED_ACTION broadcasted by the system. The RSSI should change frequently which means I should be receiving this notification frequently...however, never do I receive it once. I have watered my code down to the bare minimum so

Use of sigaction()

别说谁变了你拦得住时间么 提交于 2019-12-10 13:06:52
问题 I have to send two signals to a process, SIGUSR1 and SIGUSR2 , in order to modify a particular boolean variable in the program ( SIGUSR1 sets it to true , SIGUSR2 sets it to false ). So I wrote a signalHandler() function in order to control the behavior of SIGUSR1 or SIGUSR2 . The problem is: how to set sigaction() to handle this particular task? I spent a lot of time on Google, I read everywhere that I should use sigaction() instead of the obsolete signal() . In the man page i found this int