system/FileDescriptor: add CheckDuplicate()

This commit is contained in:
Max Kellermann
2017-09-13 17:37:28 +02:00
parent b188ae0e5c
commit a13897cf6f
2 changed files with 18 additions and 0 deletions
+8
View File
@@ -146,6 +146,14 @@ public:
bool Duplicate(int new_fd) const noexcept {
return ::dup2(Get(), new_fd) == 0;
}
/**
* Similar to Duplicate(), but if destination and source file
* descriptor are equal, clear the close-on-exec flag. Use
* this method to inject file descriptors into a new child
* process, to be used by a newly executed program.
*/
bool CheckDuplicate(int new_fd) noexcept;
#endif
#ifdef USE_EVENTFD