Method: OpenC3.run_process_check_output
- Defined in:
- lib/openc3/top_level.rb
.run_process_check_output(command) ⇒ Object
Executes the command in a new Ruby Thread. Will print the output if the process produces any output
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/openc3/top_level.rb', line 170 def self.run_process_check_output(command) thread = nil thread = Thread.new do output, _ = Open3.capture2e(command) if !output.empty? # Ignore modalSession messages on Mac Mavericks new_output = '' output.each_line do |line| new_output << line if !/modalSession/.match?(line) end output = new_output if !output.empty? Logger.error output self.write_unexpected_file(output) end end end # Wait for the thread and process to start sleep 0.01 until !thread.status.nil? sleep 0.1 thread end |