Hi ,
In my program, for a process A executing operation, there are multiple threads created.
One of the thread A checks whether process is active or not
Second thread B executes a function
One of the periodic thread C calls a callback function that executes an audit after every 30 secs.
In the audit , the function uses g_spawn_commmand_line_sync() function to spawn a child process that executes a command line (shell script).
Since g_spawn_commmand_line_sync() spawns a new child process .
In the error case scenario, the spawned child process got stuck and became zombie process. It did not get killed.Also it acquired sockets which were assigned to a thread B executing operation.
Even though the thread B got terminated ,the child process did not release the sockets that were connected to it.
My question is ,I have to automate this in C program that if it finds spawned process of g_spawn_commmand_line_sync() defunct, the
health check thread B should be able to clean it without klling the main process.
i could not find any spawn function that will help me find the PID of g_spawn_commmand_line_sync() spawned process.
I get the details from ps commands. But how can I find it in a c-program?