title: How do I reopen STDIN after closing it?
body: <p>I want to "silence" STDIN for the duration of a child process I'm spawning, so that after waiting for it to finish, nothing the user typed into the keyboard is propagated to the parent process. (If I don't, all keystrokes arrive at the parent process in a batch after the child process terminates.)</p>
  
  <p>I tried closing <code>$stdin</code>, then <code>reopen</code>ing it:</p>
  
  <pre><code>    stdin_orig = $stdin.dup
      $stdin.close
      @pid = fork do
        exec cmd
      end
      Process.wait @pid
      $stdin.reopen(stdin_orig)
  </code></pre>
  
  <p>But this throws:</p>
  
  <pre><code>in `reopen': closed stream (IOError)
  </code></pre>
  
  <p>How do I reopen standard in? Or is there a better way to ignore user input for the duration of a child process running?</p>