title: How to properly accept input from another terminal (say, pts/1)?
body: <p>I tried printing into another terminal by simply using</p>
  
  <pre><code>fd=open("/dev/pts/0",O_RDWR);
  write(fd,"hello",5);
  </code></pre>
  
  <p>and it worked properly. However I tried to read a series of characters in the same way and it appeared that the order of input was inconsistent.</p>
  
  <pre><code>fd=open("/dev/pts/0",O_RDWR);
  read(fd,&amp;ch1,1);
  read(fd,&amp;ch2,1);
  read(fd,&amp;ch3,1);
  </code></pre>
  
  <p>and I entered data "abcde" in pts/0, but when I printed the output I got "acd" and sometimes I would get "bce". Can someone explain this behavior? I read somewhere that Unix does not allow input from other terminals but even so how are these characters being received by the program running in pts/1?</p>