wait for childs of a child process

Gauvain Pocentek <[email protected]>
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <[email protected]>
Hello,

I have to monitor applications on a system (users who run the application, how
long, etc.), but I'm having troubles with applications which fork during startup
(openoffice for instance).

Here is a snippet of what I planned to use (checks omitted to simplify):

####################################
#include <stdio.h>
#include <sys/wait.h>
#include <sys/types.h>

int main()
{
    int status;
    pid_t p = fork();
    if (p == 0)
        system ("soffice");
    else if (p > 0)
    {
        waitpid (p, &status, 0);
        printf ("done\n");
    }

    return 0;
}

####################################

Is there a way to make wait() or an other syscall monitor the process' children,
or is patching openoffice (and other apps behaving in the same way) the only
solution?

Thanks,
Gauvain Pocentek
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.