🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Restart a process

Started by
0 comments, last by Bregma 15 years, 6 months ago
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
Advertisement
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).

Stephen M. Webb
Professional Free Software Developer

This topic is closed to new replies.

Advertisement