Restart a process
Hey,
i have a commandline process and want be able to restart it. I do something liek this:
void CConnectionServer::restart()
{
logger.log(ELMT_Info, "Restarting Server...", false);
s32 id = fork();
if (id < 0)
{
perror("fork");
logger.write("Ooops");
logger.log(ELMT_Warning, "Could not fork processes");
}
else if (id == 0)
{
onet::sleep(10000);
execl ("./ConnectionServer", "PFMain", NULL);
}
else
{
logger.write("Done!");
this->shutdown();
}
}
Hoever it makes the terminal think that the process has endne and a new promt gets created on the screen...
Is there a better way to restart a process by itself?
My Blog - http://www.freakybytes.org
If you are asking how a daemon process (a process that runs detached from a controlling terminal and a process group leader), that's what you need to google for. There are plenty of resources out there on how to program a daemon process.
Traditionally, on Unix, server processes are daemon processes initially started from the init system (either through inittab, or a SYSV or BSD rc script).
Traditionally, on Unix, server processes are daemon processes initially started from the init system (either through inittab, or a SYSV or BSD rc script).
Stephen M. Webb
Professional Free Software Developer
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement