[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

File.popen/IO.popen

hariwise

5/20/2006 1:06:00 AM

Hi:

>From ruby code, I am executing another command and reading the output
using File.popen.
The external command might run for a long time and I was to ensure that
if the ruby interpreter is terminated, the process that is executing
the command is cleaned up as well.

How do I accomplish this ? I am working in windows.

Thanks.

1 Answer

Robert Klemme

5/20/2006 8:20:00 AM

0

hariwise@gmail.com wrote:
> Hi:
>
>>From ruby code, I am executing another command and reading the output
> using File.popen.
> The external command might run for a long time and I was to ensure that
> if the ruby interpreter is terminated, the process that is executing
> the command is cleaned up as well.
>
> How do I accomplish this ? I am working in windows.

At least under cygwin this should work: use method #pid of the IO object
created by popen() to record the process id. Then trap SIGINT (or
whatever) and send it via Process.kill to the child process.

Kind regards

robert