title: Send Ctrl-C to process open by Java
body: <p>Under Windows OS.</p>
  
  <p>I start a sub-process via a Runtime.getRuntime().exec();
  I want to send a "ctrl-c" to the process to stop it.</p>
  
  <p>I did a small example, with Runtime.getRuntime().exec("ping google.com -n 100000");
  The code can be found there : <a href="http://pastebin.com/f6315063f" rel="noreferrer">http://pastebin.com/f6315063f</a></p>
  
  <p>So far, I tried to send the char '3' (ctrl-C character) via Process outputStream.</p>
  
  <p>Here is a bit of code:</p>
  
  <pre><code> cmd = re.exec("ping google.com -n 10000"); 
   out = new BufferedWriter (new OutputStreamWriter(cmd.getOutputStream()));
   input =  new BufferedReader (new  InputStreamReader(cmd.getInputStream()));
  
  
   char ctrlBreak = (char)3;
   //Different testing way to send the ctrlBreak;
   out.write(ctrlBreak);
   out.flush();
   out.write(ctrlBreak+"\n");
   out.flush();
  </code></pre>
  
  <p>I don't want to kill the process, I just want to send a Ctrl-C signal.
  How can I do that?</p>