signals

Is it possible to signal handler to survive after “exec”?

依然范特西╮ 提交于 2019-11-28 23:49:06
问题 I wrote a signal handler for a process, and fork() after that, the signal handler will be applied to both parent and child processes. If I replace the child process with "exec", the signal handler is no more. I know this happens because "exec" call will overwrite the child process address space with it's own. I just want to know if there is a way to make signal handler work even after "exec" call ? 回答1: No. From the man pages: execve() does not return on success, and the text, data, bss, and

standard way to perform a clean shutdown with Boost.Asio

喜夏-厌秋 提交于 2019-11-28 23:37:41
问题 I'm writing a cross-platform server program in C++ using Boost.Asio. Following the HTTP Server example on this page, I'd like to handle a user termination request without using implementation-specific APIs. I've initially attempted to use the standard C signal library, but have been unable to find a design pattern suitable for Asio. The Windows example's design seems to resemble the signal library closest, but there's a race condition where the console ctrl handler could be called after the

Sound synthesis with C#

给你一囗甜甜゛ 提交于 2019-11-28 23:28:09
问题 Is there some possibility to generate sounds in C#? I mean not just beep or open and play wave-file. I mean build the signal using different kinds of waves (sin, saw, etc.) and their options (frequencies, amplitudes, etc.) 回答1: Check out NAudio on codeplex. NAudio is an open source .NET audio and MIDI library, containing dozens of useful audio related classes intended to speed development of audio related utilities in .NET. It has been in development since 2001 and has grown to include a wide

Which thread handles the signal?

*爱你&永不变心* 提交于 2019-11-28 21:39:09
I have 2 threads(thread1 and thread2). And I have signal disposition for SIGINT . Whenever SIGINT occurs thread 2 should handle the signal. For that I wrote below program void sig_hand(int no) //signal handler { printf("handler executing...\n"); getchar(); } void* thread1(void *arg1) //thread1 { while(1) { printf("thread1 active\n"); sleep(1); } } void * thread2(void * arg2) //thread2 { signal(2, sig_hand); while(1) { printf("thread2 active\n"); sleep(3); } } int main() { pthread_t t1; pthread_t t1; pthread_create(&t1, NULL, thread1, NULL); pthread_create(&t2, NULL, thread2, NULL); while(1); }

Android Fatal Signal 11

半世苍凉 提交于 2019-11-28 19:59:43
In the app I'm developing on Android, I keep getting a Fatal Signal 11 error. I think it's something to do with the way that I'm accessing the memory but I can't figure out what is causing it. Any help will be much appreciated! Here's the LogCat: 05-02 23:47:17.618: D/dalvikvm(590): GC_FOR_ALLOC freed 68K, 4% free 6531K/6787K, paused 101ms 05-02 23:47:17.638: I/dalvikvm-heap(590): Grow heap (frag case) to 7.619MB for 1228816-byte allocation 05-02 23:47:17.738: D/dalvikvm(590): GC_CONCURRENT freed 1K, 4% free 7730K/8007K, paused 5ms+14ms 05-02 23:47:17.878: D/dalvikvm(590): GC_FOR_ALLOC freed

How do I mock a django signal handler?

人走茶凉 提交于 2019-11-28 19:07:05
I have a signal_handler connected through a decorator, something like this very simple one: @receiver(post_save, sender=User, dispatch_uid='myfile.signal_handler_post_save_user') def signal_handler_post_save_user(sender, *args, **kwargs): # do stuff What I want to do is to mock it with the mock library http://www.voidspace.org.uk/python/mock/ in a test, to check how many times django calls it. My code at the moment is something like: def test_cache(): with mock.patch('myapp.myfile.signal_handler_post_save_user') as mocked_handler: # do stuff that will call the post_save of User self.assert

Coming back to life after Segmentation Violation

我的梦境 提交于 2019-11-28 18:53:39
Is it possible to restore the normal execution flow of a C program, after the Segmentation Fault error? struct A { int x; }; A* a = 0; a->x = 123; // this is where segmentation violation occurs // after handling the error I want to get back here: printf("normal execution"); // the rest of my source code.... I want a mechanism similar to NullPointerException that is present in Java, C# etc. Note : Please, don't tell me that there is an exception handling mechanism in C++ because I know that, dont' tell me I should check every pointer before assignment etc. What I really want to achieve is to

Load MIT-BIH Arrhythmia ECG database onto MATLAB

邮差的信 提交于 2019-11-28 18:51:52
I am working on ECG signal processing using neural network which involves pattern recognition. As I need to collect all the data from Matlab to use it as test signal, I am finding it difficult to load it on to the Matlab. I am using MIT Arrhythmia database here . The signal needs to be indexed and stored as data structure in Matlab compatible format. Presently, the signal is in .atr and .dat format. How can you load MIT-BIH Arrhythmia database onto Matlab? You can use physionet ATM to get .mat files which are easier to work with. In the input part select the desired leads, length, database and

PyQt proper use of emit() and pyqtSignal()

╄→гoц情女王★ 提交于 2019-11-28 18:22:24
I am reading through some documentation on PyQt5 to come up with a simple signal-slot mechanism. I have come to a halt due to a design consideration. Consider the following code: import sys from PyQt5.QtCore import (Qt, pyqtSignal) from PyQt5.QtWidgets import (QWidget, QLCDNumber, QSlider, QVBoxLayout, QApplication) class Example(QWidget): def __init__(self): super().__init__() self.initUI() def printLabel(self, str): print(str) def logLabel(self, str): '''log to a file''' pass def initUI(self): lcd = QLCDNumber(self) sld = QSlider(Qt.Horizontal, self) vbox = QVBoxLayout() vbox.addWidget(lcd)

Why do you need a while loop while waiting for a condition variable

那年仲夏 提交于 2019-11-28 17:59:01
Say you have this code pthread_mutex_lock(&cam->video_lock); while(cam->status == WAIT_DISPLAY) // <-- Why is this a 'while' and not an 'if'? pthread_cond_wait(&cam->video_cond, &cam->video_lock); pthread_mutex_unlock(&cam->video_lock); My question is, why do you need a while loop here. Wouldn't pthread_cond_wait just wait until the signalling thread signals cam_video_cond ? OK, I know you might have a case where cam->status is not equal to WAIT_DISPAY when pthread_cond_wait is called, but in that case you could just check it through an if condition rather than using while . Am I missing