[Win32utils-devel] win32/service... still with problems.

Luis Lavena luislavena at gmail.com
Tue May 23 08:28:08 EDT 2006

On 5/22/06, Heesob Park <phasis at gmail.com> wrote:
> As you know,the win32-service is multithreaded application.
> But, Ruby's sleep or select is not compatible with the Thread of Windows.
> While executing sleep or select in ruby code,the other thread cannot
> do anything.
> To workaround this stopping problem,
> 1. Use loop of short sleep insthead of long sleep.
> ex) 10.times { sleep 1 } instead of sleep 10
> 2. Use nonblocking IO and socket.
Understand that, but wanted to "remark" that anything that take more
than 1 seconds to cleanup in service_main get terminated, no matter if
service_main finished or not.

> The workaround of stopping problem for now is separate service control
> process and working process.
> In service_main, use system,fork or something create another ruby
> program for working process and send kill to it when stop requested.
That will create 2 ruby process, one for the service (which will
depend of svchost.exe) and a child process...

If I send a kill signal, the child process will not cleanup properly,
something we must avoid in a good coded application.

For that approach, using srvany uses less memory than another ruby
process... (just loading the service.so and no other things we use 6MB
of memory).

Anyway, long live to the threading model of Ruby! (better yet, hate
Windows Threads).

Another workaround will be create a native (compiled) exe that
redirect stdin/stdout of the childprocess and execute the Cntrl-C to
finish it properly. I could do it with 30k exe and less than 1.5mb

> Regards,
> Park Heesob

Thank you for the time you and Dan took answering my mails and testing
the scripts.


Luis Lavena
Multimedia systems
Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

More information about the win32utils-devel mailing list