signals

Is it a good practice to call pthread_sigmask in a thread created by std::thread?

烂漫一生 提交于 2019-12-24 03:30:01
问题 1) I'm new to std::thread and I would like to know whether it is a good practice to call pthread_sigmask() to block some signals in a particular thread created by std::thread . I don't want the new thread to receive signals such as SIGTERM, SIGHUP, etc., because the main process has already installed handlers for these signals. So, is it a good practice to call pthread_sigmask() to block some signals in a thread created by std::thread ? 2) Also, I believe the effect of pthread_sigmask(SIG

PyQt event emmitted twice

被刻印的时光 ゝ 提交于 2019-12-24 03:17:42
问题 I'm trying to implement drag-n-drop'in' items from QListWidget to QGraphicsView . I've inherited my own class MooView from QGraphicsView and encapsulated dragMove , dragEnter and drop events. But while testing this out, i've noticed that each event is emmitted twice. Here's my MooView code: from PyQt4 import QtCore, QtGui class MooView(QtGui.QGraphicsView): def __init__(self, parent = None): QtGui.QGraphicsView.__init__(self, parent) self.handlers = {} self.handlers['dragEnter'] = [] self

Proper way to chain signal handlers in linux?

淺唱寂寞╮ 提交于 2019-12-24 02:02:11
问题 I've got a couple signal handlers I'm using to exit my program cleanly, and I'd like to play nicely with whatever else has hooked them by chaining the signal handlers calls. I'm using sigaction per the man page for signal saying it's not preferred anymore. Looking at the sigaction struct, there's signal masks and such that are specified, along with several flags. What's the "right" way to call the currently installed handler so that all those options are taken into account? 回答1: The answer is

nptl SIGCONT and thread scheduling

眉间皱痕 提交于 2019-12-24 01:16:28
问题 I'm trying to port a code that relies on SIGCONT to stop certain threads of an application. With current linux nptl implementation seems one can't rely on that in 2.6.x kernels. I'm trying to devise a method to stop other threads. Currently I can only think on mutexes and condition variables. Any hints is appreciated. 回答1: If you are relying on stopping and resuming other threads, then your application will eventually fail. That is because, you cannot guarantee that you're not going to stop a

Timer and pthreads (POSIX)

余生长醉 提交于 2019-12-24 01:07:17
问题 I'm using a pthread to schedule some tasks on my application. I copied the code from my old C version of the same application and it worked perfectly. Now I'm coding with C++ and it doesn't work anymore (basically it doesn't trigger the sigevent executing the given function). All creation and starting functions exit with rc 0, even when i use the timer_gettime. I simplified a lot the code to narrow down the issue but I could't find it yet: #include <signal.h> #include <time.h> int main (void)

QSlider and Key Press Event

徘徊边缘 提交于 2019-12-24 01:01:10
问题 I currently have a QSlider that scrolls through frames of image data using the mouse. I would like to be able to use the arrow keys to scroll through a single step (one frame). This is my current sliderMoved code: def sliderMoved(self,val): """ retrieves the data array for the index value specified by the slider """ if self.fileheader is None: print "[DEBUG] change_image_index(): self.fileheader is None" return idx=val self.x=idx frame=self.fileheader.frameAtIndex(idx) image=scipy.ndimage

SIGALRM while sleeping on Solaris 9

a 夏天 提交于 2019-12-23 21:43:50
问题 I'm running into a bit of a weird error while running Perl in a chroot environment on Solaris 9 (Sparc). We are using a custom Perl, but it's almost exactly Perl 5.8.7, and this version has been running for years on various platforms including Solaris 8-10. The following code is pretty straightforward: #!/usr/bin/perl use strict; use warnings; print "About to sleep(1)\n"; sleep 1; print "Just woke up!\n"; However, if I run that, "Just woke up!" never gets printed - instead, the program ends

How can I tell whether SIGILL originated from an illegal instruction or from kill -ILL?

半世苍凉 提交于 2019-12-23 21:27:59
问题 In a signal handler installed through void (*sa_sigaction)(int, siginfo_t *, void *); , how can I tell whether a SIGILL originated from an illegal instruction or from some process having sent SIGILL? I looked at si_pid of siginfo_t, but this seems to be uninitialized in case an illegal instruction was encountered, so that I can't base my decision on it. - Of course, I'm searching for a preferably simple and portable solution, rather than reading the instruction code at si_addr and trying to

msgrcv - SA_RESTART flag doesn't work

无人久伴 提交于 2019-12-23 21:11:51
问题 There is something wrong with my code that uses IPC queue to communicate between threads. I need to handle SIGINT safely - let program finish all active threads when SIGINT appeared before shutting down. Though, I have serious problem of finding solution because even with sigaction for SIGINT with flag SA_RESTART the msgrcv function is getting EINTR error. My question is - is there any way to avoid EINTR with msgrcv function other than specifying the error condition in some "if" such as: if

Formatted I/O inside signal handler

孤人 提交于 2019-12-23 20:17:34
问题 I'd like to write a SIGSEGV handler that writes messages to a file (FILE *). I've heard that fprintf is not reentrant and should not be called inside a signal handler. Is there a reentrant version of it, or any other function that provides formatted file I/O that can be called inside a signal handler? 回答1: No. According to §7.14.1.1 ¶5 of version N1570 of the C11 standard: If [the] signal occurs […], the behavior is undefined if […] the signal handler calls any function in the standard