On 8/31/06, Thiago Arrais <thiago.arrais / gmail.com> wrote:
> 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 = fork do
>   system 'runserver'
> end
>
> Then I could use the returned PID to send the process a signal by
> using Process.kill.

For unix, you might want to check out the rubygem called 'daemons'.
If you are not setup with rubygems, you could also download it from:

http://rubyforge.org/projects/daemons/

If what you are writing is meant to be a standard unix daemon, which
implies a number of things about how it should behave, then this
daemons package will handle many of the details that you might
not be aware of.

I only use the daemons package on unix, and I suspect that it does
not work on Windows.

> But, as far as i know, fork unfortunately doesn't work on Windows.

My guess is that you need to write your script to do one set of things
under Unix, and something else when it is run under WIndows.
But maybe someone else will have a useful solution for you.

-- 
Garance Alistair Drosehn     =             drosihn / gmail.com
Senior Systems Programmer
Rensselaer Polytechnic Institute;             Troy, NY;  USA