Jarod_Zhu
(Jarod Zhu)
1
Hi, all
I want to use system method to run a background process, like
system("ruby deamon.rb") # the deamon.rb runs a dead loop
When my main process ends, I want to end the background process
too.
How can I do it?
If I can get the pid of background process, I can use
Process.kill. But the system method dosen't return the pid.
Does anyone here know the solution?
Thank you
Jarod Zhu
The basic answer is to use IO.popen() - see
http://www.ruby-doc.org/core/classes/IO.html#M002267
For more advances applications you may want to take a look at Daemons:
http://daemons.rubyforge.org/
···
On Mon, Dec 1, 2008 at 12:29 PM, Jarod Zhu <zhujie2003info@gmail.com> wrote:
Hi, all
I want to use system method to run a background process, like
system("ruby deamon.rb") # the deamon.rb runs a dead loop
When my main process ends, I want to end the background process
too.
How can I do it?
--
Avdi
Home: http://avdi.org
Developer Blog: Avdi Grimm, Code Cleric
Twitter: http://twitter.com/avdi
Journal: http://avdi.livejournal.com
Jarod_Zhu
(Jarod Zhu)
3
IO.popen() works well.
Thanks a lot!!
Jarod Zhu
···
For more advances applications you may want to take a look at Daemons:http://daemons.rubyforge.org/
--
Avdi
Home:http://avdi.org
Developer Blog:Avdi Grimm, Code Cleric
Twitter:http://twitter.com/avdi
Journal:http://avdi.livejournal.com