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.
in A, is there any method to know whether this is in sighandler function? Thank you.
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)
|All times are GMT -5. The time now is 08:08 PM.|