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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top