[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

process fire and forget?

Michael Ulm

11/29/2004 9:15:00 AM

Is there a ruby way of firing up a process and then
forget about it?

I have a program that processes some data, and sometimes
forks off a process that creates a file from part of the
data. I want then to automatically open a text editor on
that file. Rubys involvement with the file stops there.
However, making just a system call to start the editor
lets the thread hang around until the user closes the
editor. This seems a bit of a waste of resources.

I need a platform independent solution btw, since this
should run (at least) on three different hardware/OS
combinations.

Thanks,

Michael

--
Michael Ulm
R&D Team
ISIS Information Systems Austria
tel: +43 2236 27551-219, fax: +43 2236 21081
e-mail: michael.ulm@isis-papyrus.com
Visit our Website: www.isis-papyrus.com


1 Answer

Yukihiro Matsumoto

11/29/2004 9:18:00 AM

0

Hi,

In message "Re: process fire and forget?"
on Mon, 29 Nov 2004 18:14:30 +0900, Michael Ulm <michael.ulm@isis-papyrus.com> writes:

|Is there a ruby way of firing up a process and then
|forget about it?

--------------------------------------------------------- Process#detach
Process.detach(pid) => thread
------------------------------------------------------------------------
Some operating systems retain the status of terminated child
processes until the parent collects that status (normally using
some variant of +wait()+. If the parent never collects this status,
the child stays around as a _zombie_ process. +Process::detach+
prevents this by setting up a separate Ruby thread whose sole job
is to reap the status of the process _pid_ when it terminates. Use
+detach+ only when you do not intent to explicitly wait for the
child to terminate. +detach+ only checks the status periodically
(currently once each second).