signals

longjmp() from signal handler

I'm using the following code to try to read an input from user and timeout and exit if more than 5 seconds pass. This is accomplished through a combination of setjmp/longjmp and the SIGALRM signal. Here's the code: #include <stdio.h> #include <setjmp.h> #include <unistd.h> #include <string.h> #include <sys/signal.h> jmp_buf buffer; /...

Throwing an exception from within a signal handler

We have a library that deals with many aspects of error reporting. I have been tasked to port this library to Linux. When running though my little test suite, one of the tests failed. A simplified version of the test appears below. /* Compiler: 4.1.1 20070105 RedHat 4.1.1-52 Output terminate called after th...

How can I get a human-readable description from a signal number?

Does the POSIX standard or another C standard provide a way to recover a meaningful message from a signal number, in the same way that strerror() makes it possible to recover a message from errno? The Gnu C library has strsignal(), but if possible, I would like something portable to BSD and other Unix variants. ...

C++ Server is terminating if the front end Tomcat is killed. Error "Received untrapped signal [13] - SIGPIPE"

I am facing a problem in my C++ server program. The request XML comes from the front end (Java) and the back end server (C++) process the request and returns the reply XML. As part of testing after submitting the request to back-end we killed the Tomcat server. The back-end application (threaded server application) after processing the ...

catching write faults on write protected memory

I am trying to catch write faults on write protected memory pages from my program. I have done following to achieve this : protect memory page using mprotect() : allowing only read access register signal handler for SIGSEGV called write-fault-handler using sigaction() inside signal handler : siginfo->si_addr gives me memory addres...

Explicitly calling a destructor in a signal handler

I have a destructor that performs some necessary cleanup (it kills processes). It needs to run even when SIGINT is sent to the program. My code currently looks like: typedef boost::shared_ptr<PidManager> PidManagerPtr void PidManager::handler(int sig) { std::cout << "Caught SIGINT\n"; instance_.~PidManagerPtr(); //PidManager is a...

send SIGINT to child process

I am trying to create a child process and then send SIGINT to the child without terminating the parent. I tried this: pid=fork(); if (!pid) { setpgrp(); cout<<"waiting...\n"; while(1); } else { cout<<"parent"; wait(NULL); } but when I hit C-c both process were terminated ...

SIGINT handling and getline

I wrote this simple program: void sig_ha(int signum) { cout<<"received SIGINT\n"; } int main() { string name; struct sigaction newact, old; newact.sa_handler = sig_ha; sigemptyset(&newact.sa_mask); newact.sa_flags = 0; sigaction(SIGINT,&newact,&old); for (int i=0;i<5;i++) { cout<<"Enter text: "; getline(cin,name)...

Simple Signals - C programming and alarm function

#include <stdio.h> #include <signal.h> void ALARMhandler(int sig) { signal(SIGALRM, SIG_IGN); /* ignore this signal */ printf("Hello"); signal(SIGALRM, ALARMhandler); /* reinstall the handler */ } int main(int argc, char *argv[]) { alarm(2); /* set alarm clock */ while (1...

Python PyKDE and KWindowSystem signal calling.

I'm currently slamming my head against the table trying to get a QObject.connect to work with KWindowSystem, with PyKDE, my code is as follows: from PyKDE4.kdecore import * from PyKDE4.kdeui import * from PyQt4.QtCore import * #Omitted Stupid KApplication parts. def winCheck(WId): print WId kWinSys = KWindowSystem.self() QObject....

Handling segfault signal SIGSEGV need to determine the cause of segfault using siginfo_t

Im making a wrapper for the pthread library that allows each thread to have its own set of non-shared memory. Right now the way c is set up if any thread tries to rwe another threads data, the program segfaults. This is fine, I can catch it with a sighandler and call pthread_exit() and continue on with the program. But not every segfaul...

How do I send and receive real-time signals `sigqueue()` in Python?

Python provides a signals module and os.kill; does it have a facility for sigqueue() (real-time signals with attached data)? What are the alternatives? ...

How to know when a schedule() call is returning because of a signal?

In a device driver for some PCI hardware, I have an ioctl call that waits for an incoming interrupt on the PCI bus. Using wait_queue_head_t, I put the task to sleep by calling schedule(). Then, the irq_handler function wakes up this task when the interrupt is raised on the PCI bus. Everything seems to work correctly. My question is how...

sending a signal to a background process

Which signal should I send to a background process to move it foreground? SIGTTIN, SIGTOU or...? ...

How does a process come to know that it has received a signal

Hi, Please correct me if i am wrong. Here is my understanding about signals: As far as i know, signal generation and signal delivery are 2 different things. In order to generate a signal, the OS simply sets a bit in a bitarray maintained in the Process Control Block(PCB) of the process. Each bit corresponds to a particul...

Calling a Lua function from another thread

In my sample application, I have basically two threads. The main thread contains a Lua engine (which is not thread-safe) and registers some C++ functions into this engine. However, one of these functions takes too long to perform (since it downloads some file over the internet) and I want the Lua engine to continue doing other stuff wit...

how to determine the number of signals pending in the unix signal queue (Linux)

I need to find the number of signals pending in the signal queue of a thread in linux. Is there any API that is provided by Linux ? This API needs to be called from thread, other than the thread we are querying. sigpending gives the API for the calling thread. Is there any API, which takes thread id as arg, and provides some informatio...

how to intercept linux signals ? (in C)

hi everyone, I need to intercept and trace signals from any binaries, like strace does it under linux. I don't need a so verbose output like the real one strace. I just want to know how it works, how can I intercept signal and how can I trace them. Thanks in advance :) ...

Django: save multiple object signal once

Hello, I need some help with sending email when an order is placed. To illustrate the problem, following is the abstract code: class Order(models.Model): user = models.ForeignKey(User) class OrderItem(modes.Model): order = models.ForeignKey(Order, related_name='items') item = models.CharField(max_length=255) unit_price ...

Help with qt4 qgraphicsview

I've done lots of stuff with pygtk however i'm deciding to learn pyqt, im stuck at the qgraphicsview i have absolutley no idea how to get signals from the items i place on the graphics view, primarily mouse events.How do i get the mouse events from idividual items in a scene? ...