My program uses a library that installs a SIGHUP
handler. I need to add another handler.
I found here: http://stackoverflow.com/a/13290134/447503 a suggestion to restore the original handler and call raise()
, then restore my handler.
It's considered better, because you don't need to check for three-args or one-arg version of the handler and for SIG_DFL and SIG_IGN in your code.
However, raise()
returns before the original hadler is called. I restore my handler and only then my program receives the signal I just sent. So the program enters infinite loop.
PrevSigHupSignalHandler = sigset(SIGHUP,SgpCacheRefreshSignalHandler);
static void SgpCacheRefreshSignalHandler(int signo)
{
signal(SIGHUP, PrevSigHupSignalHandler);
raise(SIGHUP);
/* when it returns here .. set our signal handler again */
signal(SIGHUP, SgpCacheRefreshSignalHandler);
}
Aucun commentaire:
Enregistrer un commentaire