From: Name Name Date: 2006-07-12T12:36:55+09:00 Subject: Re: Processes and Portability Joel, if you do t.status after you thread off the system, you'll notice that it says sleeping instead of running. Pretty much the thread will make the system call and then wait on that system call to return. So that thread is owning that process in some respects, but killing that thread will in no means kill the process, since that process is on its own now. On an unrelated note, does anyone know how to kill all children pids including itself when one is given a pid? If that question is answered, I think my post will be answered. Joel VanderWerf wrote: > Name Name wrote: >> I would like to run a process concurrently (thus if the process goes to >> sleep or runs forever, I can still run other code from my main process) >> and have all standard out of that process be put into a text file. I >> would also like this code to be portable. And finally, I would like to >> be able to kill this process at any time (So I will need the pid) > > I was half expecting the following to work, but it doesn't: > > t = Thread.new do > system "sleep 100000" # or IO.popen or fork... > end > > puts "press return to stop child thread" > gets > > t.kill > > puts `ps -Af | grep sleep` > Process.wait # still waiting for child until ^C > > Killing a thread that is waiting on system() doesn't stop the child > process. > > Should this be part of the Thread abstraction? Should threads own > processes? Maybe not. Just wondering what people think... -- Posted via http://www.ruby-forum.com/.