libc - Fix more popen() issues
commit6be058eebc5e111cbd6a27d868d172241f95cdfb
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 28 Jul 2016 17:03:08 +0000 (28 10:03 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 28 Jul 2016 17:12:24 +0000 (28 10:12 -0700)
treeaaca75c645670b3e68bfdef8c1cb377aa6bbd692
parent2eca01a4442a6c5012507471a3f39c1662854cde
libc - Fix more popen() issues

* Fix a file descriptor leak between popen() and pclose() in a threaded
  environment.  The control structure is removed from the list, then the
  list is unlocked, then the file is closed.  This can race a popen
  inbetween the unlock and the closure.

* Do not use fileno() inside vfork, it is a complex function in a threaded
  environment which could lead to corruption since the vfork()'s lwp id may
  clash with one from the parent process.
lib/libc/gen/popen.c