N
Noah Roberts
The functions I am using are not standard, but this is a standard question.
I was under the understanding that you could create a Functor and use it
in place of the function pointer argument to C functions. I haven't
been able to so either I am doing it wrong or I misunderstood.
I am trying to override my signal handler for the SIGCHLD unix signal:
Engine::SIGHandler Engine::sigchld_handler;
Engine::SIGHandler::SIGHandler()
{
signal(SIGCHLD, (void (*)(int))*this);
/*
The above was also tried with (void (*)(int))this which compiles but
blows up with SIGSEGV "in Engine::sigchld_handler ()".
*/
}
void Engine::SIGHandler:perator()(int sig)
{
int status, exit_val;
pid_t pid;
if ((pid = waitpid(-1, &status, WNOHANG)) < 0)
return;
map<pid_t, Engine*>::iterator f = engine_processes.find(pid);
if (f != engine_processes.end())
f->second->handleSigChld(status);
}
So then, the question...
Is what I am attempting possible? How is it done if so?
thanks,
NR
I was under the understanding that you could create a Functor and use it
in place of the function pointer argument to C functions. I haven't
been able to so either I am doing it wrong or I misunderstood.
I am trying to override my signal handler for the SIGCHLD unix signal:
Engine::SIGHandler Engine::sigchld_handler;
Engine::SIGHandler::SIGHandler()
{
signal(SIGCHLD, (void (*)(int))*this);
/*
The above was also tried with (void (*)(int))this which compiles but
blows up with SIGSEGV "in Engine::sigchld_handler ()".
*/
}
void Engine::SIGHandler:perator()(int sig)
{
int status, exit_val;
pid_t pid;
if ((pid = waitpid(-1, &status, WNOHANG)) < 0)
return;
map<pid_t, Engine*>::iterator f = engine_processes.find(pid);
if (f != engine_processes.end())
f->second->handleSigChld(status);
}
So then, the question...
Is what I am attempting possible? How is it done if so?
thanks,
NR