mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +00:00
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
This commit is contained in:
@ -186,6 +186,12 @@ public:
|
||||
ArrayRef<const char *> ArgsFromMain,
|
||||
SpecificBumpPtrAllocator<char> &ArgAllocator);
|
||||
|
||||
// This functions ensures that the standard file descriptors (input, output,
|
||||
// and error) are properly mapped to a file descriptor before we use any of
|
||||
// them. This should only be called by standalone programs, library
|
||||
// components should not call this.
|
||||
static std::error_code FixupStandardFileDescriptors();
|
||||
|
||||
/// This function determines if the standard input is connected directly
|
||||
/// to a user's input (keyboard probably), rather than coming from a file
|
||||
/// or pipe.
|
||||
|
Reference in New Issue
Block a user