LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 11-07-2005, 08:47 PM   #1
snowing
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() {
...............
A();
}
in A, is there any method to know whether this is in sighandler function? Thank you.
 
Old 11-07-2005, 09:55 PM   #2
primo
Member
 
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)
 
  


Reply


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
Perl file handler in recursive function enemorales Programming 4 02-02-2009 03:20 PM
USB Driver Probe function not being called xtom Fedora 0 10-28-2005 03:48 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


All times are GMT -5. The time now is 03:47 PM.

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