OSDN Git Service

Support: Add a utility to remap std{in,out,err} to /dev/null if closed
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 6 Oct 2014 23:16:18 +0000 (23:16 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 6 Oct 2014 23:16:18 +0000 (23:16 +0000)
commit3ba3a4ccfd1c9d03acf0134bd3ec52cfdcac131f
tree9b1ac5e93538bef4a26e23bdf6f3c150e4dd8fb6
parent5b8cd150922cf0c67f794e51647245cac83f5841
Support: Add a utility to remap std{in,out,err} to /dev/null if closed

It's possible to start a program with one (or all) of the standard file
descriptors closed.  Subsequent open system calls will give the program
a low-numbered file descriptor.

This is problematic because we may believe we are writing to standard
out instead of a file.

Introduce Process::FixupStandardFileDescriptors, a helper function to
remap standard file descriptors to /dev/null if they were closed before
the program started.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219170 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/Process.h
lib/Support/Unix/Process.inc
lib/Support/Windows/Process.inc