# Creating Daemon Processes in Windows

**URL:** <https://www.ruby-forum.com/t/creating-daemon-processes-in-windows/95530>\
**Category:** Ruby\
**Created:** [June 5, 2006, 2:31pm UTC](https://www.ruby-forum.com/t/creating-daemon-processes-in-windows/95530 "2006-06-05T14:31:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [June 5, 2006, 2:31pm UTC](https://www.ruby-forum.com/t/creating-daemon-processes-in-windows/95530/1 "2006-06-05T14:31:05Z")

</div>

From a ruby program I would like to start another process which should  
continue to run even after the parent process dies.  
Is there any way I could achive this?

From the child process I want to start an instance of SCGI server which  
should continue to run even if the parent process dies.

After spending a while with google, I found following…

1. Fork is not present on Windows; will have to use Win32-process module  
for  
enabling fork.
2. Threads are the way to achiveve platform independence in such cases.
3. Daemons module(support for POSIX systems) can be used for creating  
daemons, but only on UNIX systems.  
[http://rubyforge.org/projects/daemons/](http://rubyforge.org/projects/daemons/).

I tried using threads from one of the methods of a controller of an RoR  
application; I have following method in my controller which gets called  
when  
a link is clicked in one of the rhtml pages.

def servst  
threads =[]  
threads\<\< Thread.new {  
system ‘cd C:\InstantRails\rails\_apps\xyz &  
C:\InstantRails\ruby\bin\ruby  
C:\InstantRails\ruby\bin\scgi\_service’  
}  
threads.each { |t| t.join}  
end

when this method is called(on click of a link in an rhtml page), I.E.  
progress bar goes on showing some progress, but never completes.  
Note: The server I intend to start does gets started; but the current  
session from where the server was started gets hung.  
I need a way to start the server and continue traversing various links  
in  
the same session.

Thanks in Advance,

Jatinder

---

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [June 5, 2006, 2:37pm UTC](https://www.ruby-forum.com/t/creating-daemon-processes-in-windows/95530/2 "2006-06-05T14:37:33Z")

</div>

From: Jatinder S. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Monday, June 05, 2006 3:29 PM

> From a ruby program I would like to start another process which should  
> continue to run even after the parent process dies.  
> Is there any way I could achive this?  
> […]  
> 3. Daemons module(support for POSIX systems) can be used for creating  
> daemons, but only on UNIX systems.  
> [http://rubyforge.org/projects/daemons/](http://rubyforge.org/projects/daemons/).

Windows has daemon-like concept named “service”. There is win32-service  
module (inside win32utils project) for working with services.

Hope this helps.

V.

---

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [June 6, 2006, 8:41am UTC](https://www.ruby-forum.com/t/creating-daemon-processes-in-windows/95530/3 "2006-06-06T08:41:59Z")

</div>

Thanks Victor!  
Win32-service helped me achieve what I intended to do.

Thanks Again,  
Jatinder
