473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Async-signal safe functions in signal handlers (unix)

Hi,

can I make sure that Python uses only async-signal safe glibc
functions in signal handlers?
For example, you must not call malloc or free in signal handlers, see
http://www.opengroup.org/onlinepubs/...l#tag_02_04_03
The reason is, that if a signal is caught while your program is in the
malloc routine, and the signal handler calls malloc or free again,
then the heap will be corrupted, probably crashing your program.
Using the Python module "signal", I can define signal handlers, but I
guess that many statements like assignments to local variables will
involve calls to functions like malloc or free.
So, is there a) any mechanism inside Python that can detect if the
current code is executed in a signal handler, or b) a list of
statements that must not be used in a Python signal handler in order
to avoid glibc function calls that are not async-signal safe?

Regards,
Michael
Jul 18 '05 #1
1 2847
> So, is there a) any mechanism inside Python that can detect if the
current code is executed in a signal handler, or b) a list of
statements that must not be used in a Python signal handler in order
to avoid glibc function calls that are not async-signal safe?


The execution of signal handlers in python is not done really asynchronous -
instead, an incoming signal is noticed and flagged to the interpreters byte
code loop - so the signal gets dealed with when the current bytecode
instruction is termintated. Read section 7.1 in the docs about the signal
module.

In other words: Don't worry, be happy.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2

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

Similar topics

8
by: Dave | last post by:
I'm using the BeginInvoke method of a delegate to invoke a thread asynchronously and then use the EndInvoke to retrieve the value. This works wonderfully until a Serviced Component is added to...
6
by: Vanessa | last post by:
I have a question regarding async mode for calling Microsoft.XMLHTTP object. Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will work again after half an hour or so without doing...
0
by: Passynkov, Vadim | last post by:
I am using Asynchronous Query Processing interface from libpq library. And I got some strange results on Solaris My test select query is 'SELECT * from pg_user;' and I use select system...
10
by: Shawn Meyer | last post by:
Hello - I am trying to write a class that has an async BeginX and EndX, plus the regular X syncronous method. Delegates seemed like the way to go, however, I still am having problems getting...
8
by: TS | last post by:
Im in a web page and call an asynchronous method in business class. the call back method is in the web page. When page processes, it runs thru code begins invoking the method then the page...
1
by: Simon Hart | last post by:
Hi, I thought I'd just open a thread in an attempt to get peoples feelers with regards to multithreading vs Async Web Service processing. Of course Web Services makes it easy to do Async...
6
by: Shak | last post by:
Hi all, Three questions really: 1) The async call to the networkstream's endread() (or even endxxx() in general) blocks. Async calls are made on the threadpool - aren't we advised not to...
1
by: jonathan | last post by:
I need to create a webpage that asynchronously loads a series of user controls onto a page. If the user control take longer than X seconds to load it should display an error message in it place....
1
by: 1388-2/HB | last post by:
I have a class file in my App_Code folder called "clsBasePage.vb" that looks like this: Public Class clsBasePage Inherits System.Web.UI.Page ...stuff... End Class It's a "page" in that it...
10
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.