/// the previous handler for the child signal (SIGCHLD)
void (*oldChildHandler)(int) = NULL;
+/// indicates if we installed our own signal handler or not
+bool installedChildHandler = false;
+
/// method pointer for activating process manager
void (ProcessManager::*_activate_manager)();
*/
bool installChildHandler()
{
- if (oldChildHandler)
+ if (installedChildHandler)
{
// already installed
return true;
oldChildHandler = signal( Signal::CHLD, handleSigChild );
if (oldChildHandler == SIG_ERR)
{
- oldChildHandler= NULL;
+ oldChildHandler = NULL;
return false;
}
+ installedChildHandler = true;
return true;
} // eo installChildHandler
*/
bool restoreChildHandler()
{
- if (!oldChildHandler)
- {
+ if (!installedChildHandler)
return false;
- }
- void(*res)(int) = signal( Signal::CHLD, oldChildHandler);
+ void(*res)(int) = signal( Signal::CHLD, oldChildHandler );
if (res == SIG_ERR)
- {
return false;
- }
- oldChildHandler= NULL;
+
+ oldChildHandler = NULL;
+ installedChildHandler = false;
+
return true;
} // eo restoreChildHandler