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

* Re: wait for childs of a child process
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Iatrou @ 2009-02-09 14:56 UTC (permalink / raw)
  To: linux-c-programming

When the date was Monday 09 February 2009, Gauvain Pocentek wrote:

> 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).

Are you sure that the process accounting on Linux doesn't cover your needs 
and you need a custom solution?

-- 
 Michael Iatrou (brzh)

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

* Re: wait for childs of a child process
  2009-02-09 14:20 wait for childs of a child process Gauvain Pocentek
  2009-02-09 14:56 ` Michael Iatrou
@ 2009-02-09 14:56 ` ben
  1 sibling, 0 replies; 4+ messages in thread
From: ben @ 2009-02-09 14:56 UTC (permalink / raw)
  To: linux-c-programming

Gauvain Pocentek a écrit :
> 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

Would not be simpler to use Unix's pacct feature ?
It may not be enabled, though, on some linux distro.

- ben
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: wait for childs of a child process
  2009-02-09 14:56 ` Michael Iatrou
@ 2009-02-09 15:29   ` Gauvain Pocentek
  0 siblings, 0 replies; 4+ messages in thread
From: Gauvain Pocentek @ 2009-02-09 15:29 UTC (permalink / raw)
  To: Michael Iatrou; +Cc: linux-c-programming

Michael Iatrou wrote:
> When the date was Monday 09 February 2009, Gauvain Pocentek wrote:
> 
>> 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).
> 
> Are you sure that the process accounting on Linux doesn't cover your needs 
> and you need a custom solution?

Well I wasn't aware that such tool existed. It will probably help to use this
instead of reinventing the wheel.

Thanks to you and ben (who had the same idea).

Gauvain

NB: sorry for the typo in the subject.

^ 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).