Erich Lin wrote: > Is there a command in ruby that when given the pid , it will terminate > all children processes of that pid including itself. > > It seems that Process.kill(9, pid) only kills the parent and not the > children. > > > thanks I'll assume you're talking about Unix, even though when this question comes up people are usually looking for something that works on Windows too. The following is only meaningful on Unix. There's no universally-valid assumption about the relationship between a process and the processes that it forks (and the processes that the children fork in turn). (In particular, processes invoked in the foreground of a shell will have a relationship with their children and grandchildren, but it's different with processes created by other means.) Try making your parent process a process-group leader. There are Ruby APIs to support this- just make sure you call them in both the parent and the child to avoid race conditions. In the child, set the process group leader after the fork but before the exec. Now if you send a signal to -n (where n is the pid of your parent process), then all of the children will get the signal too. Signal 9 is very unfriendly. Don't use it unless it's an emergency. Use SIGINT or SIGTERM instead. -- Posted via http://www.ruby-forum.com/.