title: How to simulate line break(keyboard enter) with Linux fd stdin
body: <p>Now we want to control the stdin of the running process by using Linux fd files. Here is the code.</p>
  
  <pre><code>import os, sys
  if __name__ == "__main__":
    print("Try commands below")
    print("$ echo 'foobar' &gt; /proc/{0}/fd/0".format(os.getpid()))
    import ipdb;ipdb.set_trace()
    while True:
      print("read :: [" + sys.stdin.readline() + "]")
      pass
  </code></pre>
  
  <p>We can open another terminal to echo strings info <code>/proc/$pid/fd/0</code> and the first terminal will show the input. But we can not input the "enter" signal which is like the real keyboard press.</p>
  
  <p>We have try <code>echo -en "\n"</code> which will only input the new line but not "keyboard enter".</p>