0

Launching

stdout, status = Open3.capture2("ls")
if (status == 0)
  puts("PASS")
else
  puts("FAIL")

works like a charm, however when I try to use

stdout, status = Open3.capture2("../src/bin tests/test01.txt")

to launch an executable bin with his argument's path (which works from my command line, I checked with echo $?), it seems to enter an infinite loop. I tried capture3 and popen3, same thing.

Any idea about what could be wrong?

Pypaut
  • 53
  • 8
  • What does `../src/bin` do? Under what circumstances can it enter and infinite loop? – simonwo Feb 20 '19 at 21:38
  • @simonwo It's a compiler. I guess there are many ways it could enter an infinite loop, However as said earlier, the command line works just fine and returns 0. – Pypaut Feb 21 '19 at 09:13
  • Can you write a script to look at the environment variables? It could be that they are key to success and only on the command line. It could also be that it’s not entering an infinite loop and is actually waiting for input from STDIN or another pipe for some reason. Or it may behave differently on purpose when invoked from a script. Have a read about psudeo-TTYs, and use the Ruby module to test this. – simonwo Feb 21 '19 at 16:21
  • I also noticed that calling `$bin $file` doesn't work as well in a shell script as `"$bin $file"`, it might indeed be related in some way. – Pypaut Feb 21 '19 at 20:59

0 Answers0