It is currently Tue, 30 Nov 2021 18:39:15 GMT



 
Author Message
 kill a child pid?
What would be the most proper method of killing a child process ID using
UNIX C code?  At present I use kill(childpid, SIGTERM).  Is SIGTERM to
best signal to be sending?

Scott Reilly
sreilly@utcorp{no_spam}.com



 Tue, 02 Apr 2002 03:00:00 GMT   
 kill a child pid?
On Sat, 16 Oct 1999 00:00:41 +0200, Sorisor

Isn't it dangerous to try to kill a child by sending it a signal?  The
reason I say this is because I thought that process ids could be
reused, so the pid that was given to your child process when it was
created may not be the pid of your child process when you want to kill
it.
I hope someone can clarify this, because this is something I'm trying
to deal with now as well.
======
Remove nospam information if you must reply via e-mail.

nospam.xanth...@geocities.unspammify.com
======



 Fri, 05 Apr 2002 03:00:00 GMT   
 kill a child pid?
A process can't change it's PID while it's executing, can it?  I've never seen it
happen, and if it did, I would think they would put warnings about it in the man
pages for fork() and such.


 Sun, 05 May 2002 03:00:00 GMT   
 kill a child pid?

No, a process can't change its PID.  However, a PID can change its
process.

Since a PID is just an integer, there are a finite (usually small,
like 65536) number of possible PIDs.  Therefore, on an active system,
they will eventually be reused-- some process will eventually get a
PID that was formerly used by some other (now deceased) process.  If
processes are being spawned rapidly, it's possible that in the
interval since you selected the PID to kill and when you actually kill
it, the child has exited and some other process has been given that
PID.

This is less of a problem when dealing with child processes (rather
than unrelated processes), because you have other mechanisms to
determine when it dies (wait*(), SIGCHLD, etc).  However, I'm not
aware of a way to kill a child that's entirely race-free (the child
could die and be replaced between a waitpid and a kill).  Hopefully
somebody will correct me if I'm wrong.
--

Nate Eldredge
neldre...@hmc.edu



 Sun, 05 May 2002 03:00:00 GMT   
 
   [ 4 post ] 

Similar Threads

1. obtaining child PID in a child subshell

2. how to kill a child process that runs other children processes

3. kill child and its all grad child processes?

4. Can't Kill Zombie processes, even with kill -9 (pid)

5. Does killing parent kill children?

6. killing a shell script is not killing child processes

7. Can a process kill its child if it's killed -9

8. pdksh problem : Killing child also kills parent

9. killing a shell script is not killing child processes


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software