KIlling a process inside a thread

R

Ralph Shnelvar

[Note: parts of this message were removed to make it a legal post.]

I have

@child_thread = Thread.new do
# puts "#{__FILE__} @ #{__LINE__} #{Time.now}"

stdout = `#{the_command}`
@child_thread_return_status = $?
end

and later

#child_thread.kill


This apearrs to kill the thread but not the command surrounded by the back tick.


How do I kill the comand that is the backticked executable?
 
R

Robert Klemme

2010/9/1 Ralph Shnelvar said:
I have

=A0 =A0@child_thread =3D Thread.new do
=A0 =A0 =A0# puts "#{__FILE__} @ #{__LINE__} #{Time.now}"

=A0 =A0 =A0stdout =3D `#{the_command}`
=A0 =A0 =A0@child_thread_return_status =3D $?
=A0 =A0end

and later

=A0 =A0#child_thread.kill


This apearrs to kill the thread but not the command surrounded by the bac= k tick.


How do I kill the comand that is the backticked executable?

You probably better use IO.popen then which gives you access to the
child's PID. You'll also need to handle the output returned from the
process differently depending on timeout or not timeout.

Kind regards

robert


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 

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
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top