linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PID's of processes and waiting.
@ 2004-06-23  1:50 Eric
  2004-06-23  3:18 ` Glynn Clements
  2004-06-23 15:52 ` Michael Scondo
  0 siblings, 2 replies; 4+ messages in thread
From: Eric @ 2004-06-23  1:50 UTC (permalink / raw)
  To: linux-c-programming

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

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

end of thread, other threads:[~2004-06-23 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-23  1:50 PID's of processes and waiting Eric
2004-06-23  3:18 ` Glynn Clements
2004-06-23  3:49   ` Eric
2004-06-23 15:52 ` Michael Scondo

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