dsynth - Fix master/slave pty race on fork()
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 25 Aug 2019 19:23:37 +0000 (12:23 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 25 Aug 2019 19:23:37 +0000 (12:23 -0700)
commit168bca188b0a50fca2f82a65255dd569abd42abf
treeb282e1486b1f34aaa37b282efe72d9bf73b76e68
parenta2fbacda9099588e4da2f77704eed40be2195ae5
dsynth - Fix master/slave pty race on fork()

* If we try to re-open the slave in the forked child of the WORKER monitor,
  the worker monitor may race the child when it tries to read from the
  master side fd before the child has opened the slave, causing an error.

* If we re-open the slave in the WORKER monitor then the worker monitor
  must not block when it close()s the slave descriptor after forking a
  child.  But it will if the child has written anything.

  The solution is to re-open the slave in the master but to have the
  master write 1 char to the slave after close()ing the slavefd.  The
  forked slave will read this character before proceeding, thus ensuring
  that there is no output in the buffer when the master close()es
  its slavefd.
usr.bin/dsynth/build.c