From: ben <brouits@free.fr>
To: linux-c-programming@vger.kernel.org
Subject: Re: wait for childs of a child process
Date: Mon, 09 Feb 2009 15:56:21 +0100 [thread overview]
Message-ID: <49904415.2080606@free.fr> (raw)
In-Reply-To: <49903BBC.4010802@gmail.com>
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
prev parent reply other threads:[~2009-02-09 14:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49904415.2080606@free.fr \
--to=brouits@free.fr \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).