Reputation: 4175
I have a control service that its functionality is to manage another process in the system. I have to run this process, re-run it if it's unexpectedly closed, and close it manually upon user request.
Can you please advise me how to do that in Linux? should I save the child process PID and check its state periodically? can I register to some system events that will notify me if the application running state has been changed?
Thanks in advance.
Upvotes: 0
Views: 632
Reputation: 16404
should I save the child process PID and check its state periodically?
No, if the child exits, the parent will receive signal SIGCHLD
, so you can install signal handler to react on this event.
See sigaction(2) for how to install a signal handler, see signal(7) for general information about signal.
Upvotes: 1