signals

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

半城伤御伤魂 提交于 2019-12-08 07:34:11
问题 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

How can I notify the main thread of some message on another thread without blocking and waiting?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 07:17:29
问题 I'm writing a c# component that will only be used internally at my company. The component encapsulates communication with a number of servers that particular desktop applications need to communicate with. The servers can send unsolicited messages to the component, which are 'caught' in a separate thread. I want the majority of this component to execute under the context of its creating thread. I do not wish the separate message thread to do any message processing. Instead, I would like to

Comparing FFT of Function to Analytical FT Solution in Matlab

给你一囗甜甜゛ 提交于 2019-12-08 06:36:11
问题 I am trying to compare the FFT of exp(-t^2) to the function's analytical fourier transform, exp(-(w^2)/4)/sqrt(2), over the frequency range -3 to 3. I have written the following matlab code and have iterated on it MANY times now with no success. fs = 100; %sampling frequency dt = 1/fs; t = 0:dt:10-dt; %time vector L = length(t); %number of sample points %N = 2^nextpow2(L); %necessary? y = exp(-(t.^2)); Y=dt*ifftshift(abs(fft(y))); freq = (-L/2:L/2-1)*fs/L; %freq vector F = (exp(-(freq.^2)/4))

can't get dbus signal listener to work in C with gnome multimedia keys

点点圈 提交于 2019-12-08 05:58:06
问题 I'm trying to make my own application that will listen to the media-keys in gnome using dbus. I have found a script that works in python and I'm trying to make it work by converting it to C. My c-code builds and runs correctly but it doesn't respond to the dbus signal. this python code works: #!/usr/bin/env python """Printing out gnome multi media keys via dbus-python. """ import gobject import dbus import dbus.service import dbus.mainloop.glib def on_mediakey(comes_from, what): """ gets

Can not emit QThread's signals

强颜欢笑 提交于 2019-12-08 05:23:37
问题 QT 5.1.0rc2 , msvc 2010 , Microsoft Visual Studio 2010 It is working code on Qt 4.8.4 , msvc 2008 I have compile error at #if defined( HANDLE_PROCESSING_IN_MAIN_THREAD ) if(QThread::currentThread() != this) emit started(); #endif inherited::run(); and #if defined( HANDLE_PROCESSING_IN_MAIN_THREAD ) if(QThread::currentThread() != this) emit finished(); #endif error C2660: 'QThread::started' : function does not take 0 arguments error C2660: 'QThread::finished' : function does not take 0

Catch signal in bash but don't finish currently running command

安稳与你 提交于 2019-12-08 05:23:01
问题 I would like to catch a signal ( let's focus on INT ) and not finish the currently running command so that it finishes after running signal handler. Let's say I have the following script: #!/bin/bash READY=0 ctrl_c(){ READY=1 } trap ctrl_c INT while true; do echo first sleep sleep 1 echo second sleep sleep 1 if [ $READY -ne 0 ] ; then echo -e "\n$READY" echo Exit exit fi done When I hit Ctrl C after first sleep then I get immediately dropped down to second sleep , second sleep 1 and script

How to send signal using callback called from external script?

ぐ巨炮叔叔 提交于 2019-12-08 05:10:00
问题 Introduction I'm trying to update QT GUI element basing on the state of calculations in embedded python script. I'm able to extract required values from python, but can't set a reference to c++ object to make it work. The details Let's assume python code is called (in calc.cpp) this way: void class_name::transfer(varA, varB, varC) { Py_Initialize(); emit inprogress(70); //HERE IT WORKS object module = import("__main__"); object name_space = module.attr("__dict__"); exec_file("MyModule.py",

handle SIGSEGV in Linux?

会有一股神秘感。 提交于 2019-12-08 04:24:00
问题 I need handle the SIGSEGV in my Linux app. The reason is some clean up(3-partry lib) must be done before generate core-dump. What is more, the clean up must be performed in the context of calling thread, cannot do in signal handler. So I plan in signal handler to pass the control to the calling thread, after the clean up finished, then use raise(SIGSEGV) to generate the core-dump. The real problem seems the signal_handler cannot pass the control to calling thread, no matter I use post_sem or

Django + Tastypie - user_logged_in signal doesn't work

五迷三道 提交于 2019-12-08 04:03:52
问题 I have a Tastypie ModelResource defining various endpoints which work as expected. I've now configured this ModelResource to have BasicAuthentication : class Meta: authentication = BasicAuthentication() I've defined a couple of test users through the Django Admin Interface. As per the Django 1.7 Documentation, I've created a signals.py in which I register a couple of test signals: from django.core.signals import request_finished from django.contrib.auth.signals import user_logged_in from

using zmq::poll in multithreaded c++0x11 program in combination with cntr +x or kill signal

自闭症网瘾萝莉.ら 提交于 2019-12-08 04:00:01
问题 For a custom server I intent to use the int zmq::poll( zmq_pollitemt_t * items , int nitems, long timeout = -1) . function which is I think is a wrapper around the unix poll function but includes zmq::socket_t next to file descriptors. The function works as I expected until I press ctrl+x or run $kill my_server_pid in the terminal. I would expect that the poll to terminate with -1 or throws a zmq::error_t (which derives from std::exception ) which includes a errno and the strerr message. This