I have a service, say foo, written in C++, that runs as root. There is the usual scrip, /etc/init.d/foo start|stop|restart.
At certain times, foo needs to reload itself. Normally after an upgrade has finished. But doing things like:
system("/etc/init.d/foo restart")
doesn't work since as soon as restart kills foo, the system() call obviously gets killed as well, and the restart script never executes to completion.
Is there another call I can use instead of system() that runs asynchronously as a sibling to the calling process, instead of creating a synchronous child?
Thanks!