Thread: Popen3 Problem
View Single Post
Join Date: Oct 2005
Posts: 27
Reputation: calcop is an unknown quantity at this point 
Solved Threads: 0
calcop calcop is offline Offline
Light Poster

Re: Popen3 Problem

 
0
  #2
Dec 14th, 2008
I figured it out!

It wasn't that the program wasn't exiting. Ruby didn't know how to handle a nil variable in my code.

I changed my start_read function to:

  1. def start_read( stdout , stderr )
  2. puts("Read thread is running ...")
  3. loop do
  4. # errorline = stderr.readline
  5. #puts("STDOUT #{errorline}")
  6. the_input = stdout.getc
  7. if the_input == nil # <=== This is what I added.
  8. Thread.kill(@write_thread) #
  9. break #
  10. end #
  11. nodeSendData( @node_number, the_input.chr )
  12. STDOUT.flush
  13. end
  14. end

So, when the program exits the input becomes nil. After discovering that it is nil, I killed the other thread. Everything works great now.

Thanks for nobody's help

- Matt
Reply With Quote