1

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 testchain@192.168.100.102: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

Todoroki
  • 515
  • 4
  • 12
  • 1
    This *really* smells like a case of STDIN not being closed. – the Tin Man May 05 '16 at 00:15
  • 1
    maybe you're right; If I do `Open3.popen("multichaind testchain -daemon")...`, with `stdin.close`, it doesn't hang up. Although, if I do `stdout.each_line { |line| puts line }` inside that block, it hangs. The original `multichaind testchain -daemon` quits automaticly and returns, but `stdout.each_line {}` does not. Why do you think this occurs? I think it is the same problem with `Open3.capture3`. – Todoroki May 16 '16 at 09:27

0 Answers0