How can I make Open4 interactively capture all stdout output?
===

I'm trying to execute a shell command in a Ruby script. The shell command in question (`pg_dump`) prompts the user for a password. What I would like to do is execute the shell command in a child process and have my parent process interactively enter the password.

I would like for all `stdout` and `stderr` to be captured by the parent process so that it is not displayed to user.

Here's some code. All it is supposed to demonstrate is that Open4 is able to capture `stdout` from the shell command. Unfortunately, it's not doing that.

    puts "Executing \"#{pg_dump_command}\""

    stdin = ''
    stdout = ''
    stderr = ''

    thread = Open4::background(pg_dump_command, 0 => stdin, 1 => stdout, 2 => stderr)

    while(status = thread.status)
      puts '.'

      sleep 1
    end

    puts "STDOUT: #{stdout}"
    puts "STDERR: #{stderr}"

Here's the output. Note that it prints "Password:", despite the fact that Open4 is passed a string for `stdout`.

    Executing "pg_dump -U myuser -Fc mydb > /tmp/db.dump"
    .
    Password: .
    .
    (the dots continue for as long as a password is not entered)
    STDOUT: 
    STDERR: pg_dump: [archiver (db)] connection to database "mydb" failed: FATAL:  password authentication failed for user "myuser"

What am I missing? Thanks for any help.