title: Send SIGINT to a process by sending ctrl-c to stdin
body: <p>I'm looking for a way to mimick a terminal for some automated testing: i.e. start a process and then interact with it via sending data to stdin and reading from stdout. E.g. sending some lines of input to stdin including <code>ctrl-c</code> and <code>ctrl-\</code> which should result in sending signals to the process.</p>
  
  <p>Using <code>std::process::Commannd</code> I'm able to send input to e.g. <code>cat</code> and I'm also seeing its output on stdout, but sending <code>ctrl-c</code> (as <a href="http://academic.evergreen.edu/projects/biophysics/technotes/program/ascii_ctrl.htm" rel="nofollow noreferrer">I understand that is <code>3</code></a>) does not cause <code>SIGINT</code> sent to the shell. E.g. this program should terminate:</p>
  
  <pre><code>use std::process::{Command, Stdio};
  use std::io::Write;
  
  fn main() {
      let mut child = Command::new("sh")
          .arg("-c").arg("-i").arg("cat")
          .stdin(Stdio::piped())
          .spawn().unwrap();
      let mut stdin = child.stdin.take().unwrap();
      stdin.write(&amp;[3]).expect("cannot send ctrl-c");
      child.wait();
  }
  </code></pre>
  
  <p>I suspect the issue is that sending <code>ctrl-c</code> needs the some tty and via <code>sh -i</code> it's only in "interactive mode".</p>
  
  <p>Do I need to go full fledged and use e.g. <a href="https://github.com/ticki/termion" rel="nofollow noreferrer"><code>termion</code></a> or <a href="https://github.com/jeaye/ncurses-rs" rel="nofollow noreferrer"><code>ncurses</code></a>?</p>
  
  <p><strong>Update</strong>: I confused shell and terminal in the original question. I cleared this up now. Also I mentioned <code>ssh</code> which should have been <code>sh</code>.</p>