I am designing a monitoring process. The purpose of the monitoring process is to track several configured processes. When the monitoring process detects that the process has gone down, it needs to restart the process.
I am developing code for my Linux system. This is how I developed a small prototype - the Fed details (path, arguments) about the various processes that need to be controlled. - The monitoring process did the following: 1. A signal handler for SIGCHLD was installed 2. A plug and execv to start the process to be monitored. Store the pid of child processes. 3. When the child descends, the parent receives SIGCHLD 4. Now the signal handler will be called. The handler will start the for loop in the list of previously saved files. For each pid, it checks the / proc file system for a directory matching pid. If the directory does not exist, the process restarts.
Now, my question is: - Is the above method (for checking the / proc file system) a standard or recommended mechanism for checking the functioning of the process, or should I do something like creating a channel for the ps command and scrolling the ps output? - Is there a better way to achieve my requirement?
Sincerely.
source
share