signals

GTK detecting window resize from the user

偶尔善良 提交于 2019-11-28 10:50:16
In GTK (or pygtk or gtkmm...) How can I detect that an application window has been manually resized by the user, as is typically done by dragging the window's edge? I need to find a way to differentiate manual resizes from resizes that originate from gtk, such as changes in window content. Have you tried connecting to the GDK_CONFIGURE event? Check out this example under the "Moving window" section. The example shows a callback doing something when the window is moved, but the configure event is a catch-all for moving, resizing and stack order events. I managed to pull this off by watching for

Why only async-safe functions should be called from a signal handler?

十年热恋 提交于 2019-11-28 10:48:51
问题 I understand that, from a signal handler function sigaction() I should only call those functions that are "async-safe". But why is so? 回答1: Calling an unsafe function may lead to undefined behavior. The Open Group Base Specifications Issue 7 (POSIX.1-2008), in its treatment of "Signal Concepts", says: [W]hen a signal interrupts an unsafe function ... and the signal-catching function calls an unsafe function, the behavior is undefined. As to why unsafe functions are unsafe, there may be many

signal handling

◇◆丶佛笑我妖孽 提交于 2019-11-28 10:36:14
I'm just playing with signal in Mac OS X. Why does the following code not produce the default behavior of SIGSEGV after my signal handler has finished? Under Linux, the code works fine. #include <stdio.h> #include <signal.h> #include <stdlib.h> void err_crash(); void my_signal_handler (int signal) { fprintf(stderr, "signal == %i\n", signal); fflush(stderr); err_crash(); } void err_crash() { static int count= 0; if (count) signal(SIGSEGV, SIG_DFL); /* break recursion loop if we recursed */ count++; // one of the two should really crash ;) ((void)(*((int volatile *)NULL))); *((int *)NULL) = 42;

How to send SIGINT to a remote process over SSH?

半世苍凉 提交于 2019-11-28 09:10:09
I have a program running on a remote machine which expects to receive SIGINT from the parent. That program needs to receive that signal to function correctly. Unfortunately, if I run that process remotely over SSH and send SIGINT, the ssh process itself traps and interrupts rather than forwarding the signal. Here's an example of this behavior using GDB: Running locally: $ gdb GNU gdb 6.3.50-20050815 (Apple version gdb-1344) (Fri Jul 3 01:19:56 UTC 2009) ... This GDB was configured as "x86_64-apple-darwin". ^C (gdb) Quit ^C (gdb) Quit ^C (gdb) Quit Running remotely: $ ssh foo.bar.com gdb GNU

Qt signal slot connection - QNetworkAccessManager

徘徊边缘 提交于 2019-11-28 08:56:19
问题 Im new in Qt and im trying to understand the following signal-slot connection: m_networkManager = new QNetworkAccessManager(this); QNetworkReply *reply = m_networkManager->get(request); connect(reply, SIGNAL(finished()),this, SLOT(onRequestCompleted())); Why we connect the "finished" signal after the get-request?...What happened, if the network connection in line-2 was faster executed before the slot connection (line-3) was made? I know, that this code will work. but i want to understand how

Python - How to detect when user closes a console application via “X” button

懵懂的女人 提交于 2019-11-28 08:26:09
问题 I currently have a Console based python program running under windows. The program maintains most of its data in memory and periodically saves the data to disk, or when the user shuts the application down via a Keyboard interrupt ( Ctrl + C ) event. The problem i have is that when a user hits the "X" button at the top right of the console window, the session closes and the data in memory is lost. What i am looking for is an event/signal or hook so that i can clean up the memory before closing

is SIGSEGV delivered to each thread?

谁都会走 提交于 2019-11-28 08:25:06
I have a program in Linux which is multithreaded. There are certain memory areas in which I'm interested to see if they have been written within a certain time period. For that I give only read access to those memory pages and install a signal handler for SIGSEGV. Now my question is, will each thread call the signal handler for itself. Say Thread 1 writes to some forbidden memory area, will it be the one to execute the signal handler? First of all Signal dispositions are process-wide; all threads in a process share the same disposition for each signal. If one thread uses sigaction() to

About the ambiguous description of sigwait()

元气小坏坏 提交于 2019-11-28 08:24:10
If no signal in set is pending at the time of the call, the thread shall be suspended until one or more becomes pending. The signals defined by set shall have been blocked at the time of the call to sigwait(); otherwise, the behavior is undefined. The effect of sigwait() on the signal actions for the signals in set is unspecified. This is really ambiguous ,what's the difference between pending and block here? And its conclusion on how to choose between sigwait and sigaction is not clear at all: In summary, when it is necessary for code run in response to an asynchronous signal to notify a

After suspending child process with SIGTSTP, shell not responding

…衆ロ難τιáo~ 提交于 2019-11-28 07:55:27
问题 I'm coding a basic shell in C, and I'm working on suspending a child process right now. I think my signal handler is correct, and my child process is suspending, but after that, the terminal should return to the parent process and that's not happening. The child is suspended, but my shell isn't registering any input or output anymore. tcsetpgrp() doesn't seem to be helping. Here's my signal handler in my shell code for SIGTSTP: void suspend(int sig) { pid_t pid; sigset_t mask; //mpid is the

How can I retrieve the signal strength of nearby wireless LAN networks on Windows using Python?

两盒软妹~` 提交于 2019-11-28 07:48:24
How can I retrieve the signal strength of nearby wireless LAN networks on Windows using Python? I would like to either show or graph the values. fmark If you are on Windows , you probably want to use the WLAN API , which provides the 'WlanGetAvailableNetworkList()' function (see the API docs for usage). I am not aware of any python wrappers for WLANAPI.DLL so you may have to wrap it yourself using ctypes . I have a preliminary script that does this ( works-for-me ), but it may be crufty. You'll want to read the documentation to understand the meaning of all the fields: from ctypes import *