All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric <eric@cisu.net>
To: linux-c-programming@vger.kernel.org
Subject: PID's of processes and waiting.
Date: Tue, 22 Jun 2004 20:50:48 -0500	[thread overview]
Message-ID: <200406222050.48748.eric@cisu.net> (raw)

Hello,

	I am looking for a way to wait for a process to terminate. I have a process 
that was executed via system() and am getting its PID from a file it writes 
itself. I have a few questions.

	1. Is it possible to directly get the PID of a processes executed via 
system()? I do not believe so that is why I am falling back to reading its 
file.

	2. I have tried to waitpid() on the process by giving waitpid the PID read 
from the file as an argument, however it seems to return immidietly because I 
assume the new process is not a child of the calling process. Is it in fact a 
child of the calling process or am I abusing the systemcall? I assume a child 
is created only via fork()/exec() varients and this is the reason waitpid() 
is not working.

	3. Is waiting to see when the /proc/PID directory disappears a reliable 
solution? Does this directory die on exit() and is handled by the kernel, or 
is this unreliable for one reason or another?

	I am aware that a race/deadlock may occur if a new process takes the PID of 
the old process I am waiting for in between the time I poll the directory, 
however, I am at a complete loss on how to wait on this process. I need a 
reliable indicator that the process has stopped wether gracefully or dying a 
horrible death. Currently I am polling its PID file...but that is VERY 
unreliable because it is not cleaned up on a SIGKILL.

Does anyone have any ideas?

Thanks in advance,
	Eric

             reply	other threads:[~2004-06-23  1:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-23  1:50 Eric [this message]
2004-06-23  3:18 ` PID's of processes and waiting Glynn Clements
2004-06-23  3:49   ` Eric
2004-06-23 15:52 ` Michael Scondo

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=200406222050.48748.eric@cisu.net \
    --to=eric@cisu.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.