linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* wait for childs of a child process
@ 2009-02-09 14:20 Gauvain Pocentek
  2009-02-09 14:56 ` Michael Iatrou
  2009-02-09 14:56 ` ben
  0 siblings, 2 replies; 4+ messages in thread
From: Gauvain Pocentek @ 2009-02-09 14:20 UTC (permalink / raw)
  To: linux-c-programming

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-09 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-09 14:20 wait for childs of a child process Gauvain Pocentek
2009-02-09 14:56 ` Michael Iatrou
2009-02-09 15:29   ` Gauvain Pocentek
2009-02-09 14:56 ` ben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).