Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-07-2005, 08:47 PM   #1
LQ Newbie
Registered: Jul 2005
Posts: 26

Rep: Reputation: 15
howto know whether a function is called in signal handler

I come across a problem today, could you please give some suggestions.
I wonder how to get to know whether a function is called in signal handler funtion or in normal function.
for example:
A() {

sighandler() {
in A, is there any method to know whether this is in sighandler function? Thank you.
Old 11-07-2005, 09:55 PM   #2
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
Yes. From within the signal handler function you could turn on a global variable that you could test within A().

But be careful with races, because a test for this variable could not succeed and just a microsecond later a signal could come in. Plan in case the signal handler would call A() when you're within A(). Use sig_atomic_t to ensure that any assignment to this variable would be atomic (ie, if it takes >1 machine instructions, not to be interrupted in the middle of it)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
USB Driver Probe function not being called xtom Fedora 1 11-10-2018 12:05 PM
Perl file handler in recursive function enemorales Programming 4 02-02-2009 03:20 PM
Howto write FS handler doc anywhere? virtualuk Linux - General 0 10-27-2004 01:30 PM
Konqueror / KDE Crash Handler: Signal 11 Bob P Linux - Software 4 10-13-2004 04:21 PM
can interrupt handler call user space function? pot_po Programming 0 11-07-2002 09:32 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration