def globalObjectThread
  @globalObjectThread = Thread.new() {
    Thread.exit
  }
end

def pipedStdin 
  @pipedStdin
end

def someOtherFunction() {
  globalObjectThread = Thread.new() {
     ## run some stuff here.
     pipedStdin, pipedStdout, pipedStderr = Open3.popen3("do something");
     while pipedStdout
       ## get some text from stdOut parse it here.
     end
     Thread.exit ## quit when done
  }
}

def executeSomeCommand(cmd) {
  if globalObjectThread.status
    pipedStdin.write(cmd+"\n");
  end
}