T
Thiago Arrais
I am trying to start and stop a daemon process from inside my Ruby
program. At first I tried using fork to do the job, as in
server_pid =3D fork do
system 'runserver'
end
Then I could use the returned PID to send the process a signal by
using Process.kill. But, as far as i know, fork unfortunately doesn't
work on Windows. I read somewhere I should be using Thread.new if I
want the code to be platform independent, like this:
thread =3D Thread.new do
system 'runserver'
end
The question is: how do I kill the subprocess when using threads? I
tried thread.kill and thread.stop, but they won't do the trick. When
using threads, what I get are a lot of orphan processes after the
initial Ruby program finishes.
Is there any idiomatic way of doing that in Ruby that is platform independe=
nt?
Cheers,
Thiago Arrais
--=20
Mergulhando no Caos - http://thiagoarrais.blogspot.com
Pensamentos, id=E9ias e devaneios sobre desenvolvimento de software e
tecnologia em geral
program. At first I tried using fork to do the job, as in
server_pid =3D fork do
system 'runserver'
end
Then I could use the returned PID to send the process a signal by
using Process.kill. But, as far as i know, fork unfortunately doesn't
work on Windows. I read somewhere I should be using Thread.new if I
want the code to be platform independent, like this:
thread =3D Thread.new do
system 'runserver'
end
The question is: how do I kill the subprocess when using threads? I
tried thread.kill and thread.stop, but they won't do the trick. When
using threads, what I get are a lot of orphan processes after the
initial Ruby program finishes.
Is there any idiomatic way of doing that in Ruby that is platform independe=
nt?
Cheers,
Thiago Arrais
--=20
Mergulhando no Caos - http://thiagoarrais.blogspot.com
Pensamentos, id=E9ias e devaneios sobre desenvolvimento de software e
tecnologia em geral