File.popen/IO.popen

H

hariwise

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.
 
R

Robert Klemme

Hi:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top