473,554 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what can be used in a signal handler

hg
Hi,

I posted an equivalent question earlier ... but am still not sure:

I currently (under Linux) have a program that uses Queue.put (raw_input(''))
in a signal handler and Queue.get() in the main/only thread.

It works but I want to know if it is legal / what type of synchro API I have
the right to use in a signal handler.

Regards,

hg

Jan 18 '07 #1
2 1476

In article <3z************ *******@newsfe2 1.lga>,
hg <hg@nospam.orgw rites:
|>
|I posted an equivalent question earlier ... but am still not sure:
|>
|I currently (under Linux) have a program that uses Queue.put (raw_input(''))
|in a signal handler and Queue.get() in the main/only thread.
|>
|It works but I want to know if it is legal / what type of synchro API I have
|the right to use in a signal handler.

Strictly, no and none.

C and POSIX's specifications of signal handling is a complete mess.
ALL handling of ALL real signals is undefined behaviour, though few
programmers realise that and POSIX depends on it. As that would make
all Unices (and Microsoft systems) unusable, you can reasonably assume
that there is some signal handling that will work.

But what? Which is where you came in.

The situation is that most things that seem to work do actually work,
in some environments and under some circumstances. You can never be
sure when they will stop working, however, and all bets are off when
you port signal handling code to a new system. And, really but REALLY,
do not mix it with very high levels of optimisation or rely on it
being in any way thread safe.

I can't tell you whether the code of Queue is intended to work if an
active Queue.get is interrupted by a signal which then does a Queue.put,
but that is the sort of circumstance where things get very hairy. Even
if Python has code to enable that case, it won't be 100% reliable on all
systems.

Sorry. But that is the situation :-(
Regards,
Nick Maclaren.
Jan 18 '07 #2
hg
Nick Maclaren wrote:
>
In article <3z************ *******@newsfe2 1.lga>,
hg <hg@nospam.orgw rites:
|>
|I posted an equivalent question earlier ... but am still not sure:
|>
|I currently (under Linux) have a program that uses Queue.put
|(raw_input('') ) in a signal handler and Queue.get() in the main/only
|thread.
|>
|It works but I want to know if it is legal / what type of synchro API I
|have the right to use in a signal handler.

Strictly, no and none.

C and POSIX's specifications of signal handling is a complete mess.
ALL handling of ALL real signals is undefined behaviour, though few
programmers realise that and POSIX depends on it. As that would make
all Unices (and Microsoft systems) unusable, you can reasonably assume
that there is some signal handling that will work.

But what? Which is where you came in.

The situation is that most things that seem to work do actually work,
in some environments and under some circumstances. You can never be
sure when they will stop working, however, and all bets are off when
you port signal handling code to a new system. And, really but REALLY,
do not mix it with very high levels of optimisation or rely on it
being in any way thread safe.

I can't tell you whether the code of Queue is intended to work if an
active Queue.get is interrupted by a signal which then does a Queue.put,
but that is the sort of circumstance where things get very hairy. Even
if Python has code to enable that case, it won't be 100% reliable on all
systems.

Sorry. But that is the situation :-(
Regards,
Nick Maclaren.
Fair, I'll find a way around then.

Regards,

hg
Jan 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6794
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what the issue is. Thanks Ravi
2
2199
by: lpw | last post by:
I have dilligently reviewed FAQ-lite Section 3.2, "How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc." The only suggestion on how to deliver a signal to an object is to do it via a global variable and a wrapper function, a technique that is generally a Bad Idea (due to...
3
3510
by: Martin McCormick | last post by:
A C program contains several signal statements to remove a lock file if the program gets killed: /*Set up interrupt handler to catch ctrl-C so that lock file can be removed.*/ signal(SIGINT,crash); signal(SIGBUS,crash); signal(SIGSEGV,crash); This part works. Those signals cause the "crash.c" module to run and get rid of the lock. Is...
3
2189
by: subnet | last post by:
I'm trying to write a very simple program that uses a signal-based synchronization between two processes. Here's it: ----------------------------------------------- /* The world's simplest syncronization example */ #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <unistd.h> void handler(int sig);
11
2938
by: Jackie | last post by:
Hi everyone, I'd like to know when and how signals are used (e.g. SIGFPE, SIGABRT, SIGTERM, SIGSEGV, SIGINT)? Thank you so much.
5
2602
by: Sontu | last post by:
Hi all, Consider the following code: #include<signal.h> #include<stdio.h> #include<sys/mman.h> void handler(int sig) {
4
2085
by: manochavishal | last post by:
Why would a signal handler cannot in general call standard library functions. I have read whats is said in Standard but needs an explaination on that as i couldn't uunderstand it. Thanx in advance
10
4020
by: subramanian | last post by:
Consider the following code: segment violation is deliberately generated to catch the SIGSEGV signal. The handler for this signal, namely SIGSEGV_handler, is called. However after the handler is finished, control does not return to the printf statement in main() which is present after the strcpy statement. Instead Segmentation violation error...
1
2417
by: stalex | last post by:
Hi all, I wrote the following code since I want to try using a decorator to install signal handler: ## The test.py script ################# import os import time import signal
0
7573
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7778
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7527
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5412
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3538
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3525
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1992
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1109
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.