signals

Capture SIGFPE from SIMD instruction

我是研究僧i 提交于 2019-12-06 21:13:37
I'm trying to clear the floating point divide by zero flag to ignore that exception. I'm expecting that with the flag set (no change from default behavior I believe, and commented out below), my error handler will fire. However, _mm_div_ss doesn't seem to be raising SIGFPE. Any ideas? #include <stdio.h> #include <signal.h> #include <string.h> #include <xmmintrin.h> static void sigaction_sfpe(int signal, siginfo_t *si, void *arg) { printf("inside SIGFPE handler\nexit now."); exit(1); } int main() { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sigemptyset(&sa.sa_mask); sa.sa_sigaction =

IPC研究(1) -- signals

断了今生、忘了曾经 提交于 2019-12-06 19:53:34
==================================================================== IPC ---- Signals Question: Why is it unsafe to call printf() in a signal handler? A: A signal handling fucntion could be interrupted in the middle and called again by something eles. So a signal handling function is not just recurisve, but also re-entrant. This means, any system calls that are not re-entrant but are called inside a signal handler are considered unsafe. For system calls that are safe to call inside a signal handler, refer to page 524 in Book "Linux Programming". Related system calls: signal (deprecated) kill

launchd: sleep in GCD managed signal handler

给你一囗甜甜゛ 提交于 2019-12-06 19:36:29
I encounter a strange situation in a launchd managed daemon when I try to sleep in the SIGTERM handler that is managed with Grand Central Dispatch as described here . Everything works fine and I do get a SIGTERM signal handler before receiving a SIGKILL when I do not sleep in the SIGTERM handler. But as soon as I do sleep -- even for extremly short amounts of time like a usleep(1); -- I do not get a SIGTERM handler at all but instead my daemon is SIGKILLed instantly by launchd. Btw I am using EnableTransactions in my plist file and the proper vproc_transaction_begin(3) / vproc_transaction_end

Can linux signal my Qt program when a particular USB device is connected?

泄露秘密 提交于 2019-12-06 16:48:34
I want linux to inform my Qt program by a signal when a particular USB device is connected. Storage devices like flash disk or hard drive. How can I do this? What are your suggestions? UPDATE: I have found that QtDbus can provide the functionality that I need but I have not figure out how exactly. Is there anyone can give information about getting USB device notification with QtDbus? I have been reading this tutorial: http://dbus.freedesktop.org/doc/dbus-tutorial.html This tutorial says: D-Bus is designed for two specific cases: Communication between desktop applications in the same desktop

Are django signals always synchronous?

点点圈 提交于 2019-12-06 15:40:36
I'm developing a django IPN plugin that saves IPN data to a model and then calls a post_save signal. I'm worried that under this use case (gunicorn, gevent, etc) that the signals may be called/completed asynchronously. The IPN often sends more than 1 request to the ipn url, and I need to be able to process those requests in order. Should I use a queue for this? Would simple python queue's work better, or should I use something like kombu + celery (with 1 worker)? Not sure synchronicity is your real concern here. Django's signals are always executed in-process : that is, they will be executed

Problems with $SIG{WINCH} when using it in a module

≡放荡痞女 提交于 2019-12-06 15:32:36
When I use this module in a script, the if ( $size_changed ) { remains false when I've changed the terminal size. When I copy the code from the module directly in a script (so that I don't have to load the module) it works as expected. What could it be that loading the code as a module doesn't work? use warnings; use 5.014; package My_Package; use Exporter 'import'; our @EXPORT = qw(choose); my $size_changed; $SIG{WINCH} = sub { $size_changed = 1; }; sub choose { # ... # ... while ( 1 ) { my $c = getch(); if ( $size_changed ) { write_screen(); $size_changed = 0; next; } # ... # ... } } I think

linux/glibc. Can I use fprintf in signal handler?

主宰稳场 提交于 2019-12-06 14:02:33
Can I use fprintf(stderr) in a signal (SIGALRM) handler with glibc/linux? No you cannot. Check the manpage signal(7) for a list of async-signal-safe functions. fprintf is not included in that list. If you don't need formatting then you can use write(STDERR_FILENO, <buf>, <buflen>) to write to stderr. This is not safe, quoting IBM DeveloperWorks article about Signal Handling Safety Suppose the signal handler prints a message with fprintf and the program was in the middle of an fprintf call using the same stream when the signal was delivered. Both the signal handler's message and the program's

Is it possible to make an arbitrary program ignore signals?

旧时模样 提交于 2019-12-06 13:33:55
问题 Specifically on Mac OS X, is it possible to make a program ignore SIGTERM via DYLD_INSERT_LIBRARIES, in a way which works for any or most programs? I tried compiling and inserting this: #include<stdio.h> #include<signal.h> #include<unistd.h> void sig_handler(int signo) { if (signo == SIGTERM) printf("received SIGTERM\n"); } int main(void) { signal(SIGTERM, sig_handler); return 0; } However, DYLD_INSERT_LIBRARIES=libignore.dylib sleep 60 was able to be kill -15'd without issue. 回答1: You can

What does signal(SIGCHLD, SIG_DFL); mean?

邮差的信 提交于 2019-12-06 13:28:20
I am not handling SIGCHLD in my code. Still my process is removed immediately after termination. I want it to become zombie process. If I set SIGCHLD to SIGDFT then, will it work? How do I set SIGCHLD to SIGDFT? I want process to become zombie, so I can read the child status in parent after waitpid. From your question history you seem to be tying yourself in knots over this. Here is the outline on how this works: The default disposition of SIGCHLD is ignore. In other words, if you do nothing, the signal is ignored but the zombie exists in the process table. This why you can wait on it at any

C++, linux, fork, execvp, waitpid and SIGTSP

萝らか妹 提交于 2019-12-06 13:25:31
I'm implementing a Terminal for a Home Work. I almost finished, I just need to implement a bg ( Background ) and a fg ( Foreground ) commands. my code looks like this: void run(){ string command[] = parseMyInput( getInput() ); int fork_result = fork(); if( -1 == fork_result ) //handle error else if( 0 == fork_result ){ // child setpgrp(); // I don't want the children to get the signals if( -1 == execvp( command[0], makeArgs(command) ) ) //handle error } else { // parent if( command[ length - 1 ] != "&" ){ int status; waitpid( fork_result, &status, 0 ); //continue after child is finished //(