signals

Qt - signal for when QListWidget row is edited?

拟墨画扇 提交于 2019-11-30 20:03:28
问题 I am working in Qt4.7, and I have a QListWidget in my dialog. I have a QString that needs to match the current text in the row of this widget (the individual rows are editable). Looking at the signals associated with QListWidget, there seem to be signals for when a different index is selected but none for when the text of a the currently selected row changes. I thought currentTextChanged(QString) would do it, but it didn't. I also thought to try to connect each individual row to something,

SIGKILL init process (PID 1)

こ雲淡風輕ζ 提交于 2019-11-30 19:58:25
I'm facing a weird issue regarding sending signal 9 (SIGKILL) to the init process (PID 1). As you may know, SIGKILL can't be ignored via signal handlers. As I tried sending SIGKILL to init, I noticed that nothing was happening; init would not get terminated. Trying to figure out this behaviour, I decided to attach myself to the init process with strace too see more clearly what was happening. Now comes the weird part. If I'm "looking" at the init process with strace and send it SIGKILL, the system crashes. My question is why is this happening? Why does the system crash when I look at the

SEH Equivalent in Linux or How do I handle OS Signals (like SIGSERV) and yet keep continuing

 ̄綄美尐妖づ 提交于 2019-11-30 19:08:55
I am currently working on a Unit Testing framework where users can create Test Cases and register with the framework. I would also like to ensure that if any of the User Test Code causes a Crash, it should not Crash the entire framework but should be flagged as failed. To Make this work, I wrote up the following Code so that I can run the Users Code within the Sandbox function bool SandBox(void *(*fn)(void *),void *arg, void *rc) { #ifdef WIN32 __try { if (rc) rc = fn(arg); else fn(arg); return true; } __except (EXCEPTION_EXECUTE_HANDLER) { return false; } #else #endif } This works perfectly

Readline: Get a new prompt on SIGINT

泪湿孤枕 提交于 2019-11-30 18:31:49
I've got code similar to the following, using readline: #include <errno.h> #include <error.h> #include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> #include <readline/readline.h> #include <readline/history.h> void handle_signals(int signo) { if (signo == SIGINT) { printf("You pressed Ctrl+C\n"); } } int main (int argc, char **argv) { //printf("path is: %s\n", path_string); char * input; char * shell_prompt = "i-shell> "; if (signal(SIGINT, handle_signals) == SIG_ERR) { printf("failed to register interrupts with kernel\n"); } //set up custom

Pitch detection using FFT for trumpet

ぃ、小莉子 提交于 2019-11-30 18:26:30
问题 How do i get frequency using FFT? What's the right procedure and codes? 回答1: Pitch detection typically involves measuring the interval between harmonics in the power spectrum. The power spectrum is obtained form the FFT by taking the magnitude of the first N/2 bins (sqrt(re^2 + im^2)). However there are more sophisticated techniques for pitch detection, such as cepstral analysis, where we take the FFT of the log of the power spectrum, in order to identify periodicity in the spectral peaks.

How does processes synchronization using signals work?

半世苍凉 提交于 2019-11-30 18:24:32
问题 I've recently finished Section 10 (Signals) of "Advanced Programming in the Unix Environment" (3rd edition) and I've come across a piece of code I don't entirely understand: #include "apue.h" static volatile sig_atomic_t sigflag; /* set nonzero by sig handler */ static sigset_t newmask, oldmask, zeromask; static void sig_usr(int signo) /* one signal handler for SIGUSR1 and SIGUSR2 */ { sigflag = 1; } void TELL_WAIT(void) { if (signal(SIGUSR1, sig_usr) == SIG_ERR) err_sys("signal(SIGUSR1)

How can I handle SIGINT in Erlang?

倾然丶 夕夏残阳落幕 提交于 2019-11-30 18:03:58
I know how to create custom signal handlers in Java, Python, Ruby, Perl, and Lisp, thanks to Google and a plethora of tutorials. I can't find online how to create handlers for SIGINT, SIGTERM, HUP, etc. in Erlang. You can not. OS signals handled exclusively by Erlang VM. I guess OS signals can be handled in a driver but it can interfere with the VM signal handler so use it on your own risk. I stumbled upon this: http://erlang.org/doc/man/kernel_app.html#erl_signal_server . I have not seen it formally announced anywhere, but I might have missed the announcement. 来源: https://stackoverflow.com

How do I capture SIGINT in Python on Windows?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 17:24:57
问题 (Similar to this question) On UNIX under Python 2.7, at the Python prompt: >>> import signal >>> def handler(signal, frame): ... print 'welcome to the handler' ... >>> signal.signal(signal.SIGINT, handler) <built-in function default_int_handler> I press ctrl-c >>> welcome to the handler >>> On Windows: >>> import signal >>> def handler(signal, frame): ... print 'welcome to the handler' ... >>> signal.signal(signal.SIGINT, handler) <built-in function default_int_handler> Upon pressing ctrl-c:

Guaranteeing mutex safety with async signals

落花浮王杯 提交于 2019-11-30 17:12:59
问题 First, I am aware that the mutexes are not considered async-safe normally. This question concerns the use of sigprocmask to make mutexes safe in a multithreaded program with async signals and signal handlers. I have some code conceptually like the following: struct { int a, b; } gvars; void sigfoo_handler(int signo, siginfo_t *info, void *context) { if(gvars.a == 42 || gvars.b == 13) { /* run a chained signal handler */ } } /* called from normal code */ void update_gvars(int a, int b) { gvars

Is it safe to send SIGTERM to JVM

六月ゝ 毕业季﹏ 提交于 2019-11-30 16:57:37
问题 Although JVM will translate SIGTERM and similar signals to shutdown hooks, many service shutdown scripts use a TCP port to initiate a shutdown. (e.g. Tomcat's shutdown port, Java Service Wrapper, JBoss' management interfaces, etc.) So I thought using signals and shutdown hooks to gracefully shutdown java services is discouraged, until I found that Play! framework is managing the service lifecycle with shutdown hooks and the startup scripts generated by play dist assumes that a signal will be