libc - Fix more popen() issues
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 28 Jul 2016 17:03:08 +0000 (10:03 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 29 Jul 2016 01:26:41 +0000 (18:26 -0700)
commit5b715746eadfbbefb248f3b5be0227766b4b757b
treeb70a4a36ffb6019d598aefe9567e0854da95d008
parentb4d214925c8f708d2225d8a54f8bb2fa49238618
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