Open3.capture3 hangs without any outputs

190 Views Asked by At

I have some codes like this in pry:

[1] pry(main)> require 'open3'
=> true

[2] pry(main)> output, error, status = Open3.capture3("multichain-util create testchain")
=> ["MultiChain utilities build 1.0 alpha 20 protocol 10005\n\nBlockchain parameter
    set was successfully generated.\nYou can edit it 
    in /home/me/.multichain/testchain/params.dat before running multichaind for the first 
    time.\n\nTo generate blockchain please run \"multichaind testchain -daemon\".\n",
    "",
    #<Process::Status: pid 13944 exit 0>]

which uses multichain in command line. Although the above works good, the next part doesn't work:

[3] pry(main)> output, error, status = Open3.capture3("multichaind testchain -daemon")

^CInterrupt: 
from /home/me/.rbenv/versions/2.3.0/lib/ruby/2.3.0/open3.rb:271:in `value'

I wait for ages but it never return anything until I interrupt it by ctrl-C. multichaind -daemon doesn't wait for any other inputs.

I get the next output when I run multichaind from bash:

$ multichaind testchain -daemon

MultiChain Core Daemon build 1.0 alpha 20 protocol 10005

MultiChain server starting
Looking for genesis block...
Genesis block found
New users can connect to this node using
multichaind [email protected]:2681

Node started

and quits. Does anyone have any ideas of why capture3 hangs? Thanks,

EDIT: the Tin Man told me that this problem is about not closing STDIN, but I believe that Open3.capture3 automatically closes STDIN. And after I done it in Open3.popen3, the problem was about the STDOUT. Can someone tell me more about this? thanks

0

There are 0 best solutions below