[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Fri May 2 07:04:53 PDT 2025
================
@@ -122,8 +123,14 @@ struct ForkLaunchInfo {
ExitWithError(error_fd, "close");
break;
case FileAction::eFileActionDuplicate:
- if (dup2(action.fd, action.arg) == -1)
- ExitWithError(error_fd, "dup2");
+ if (action.fd != action.arg) {
+ if (dup2(action.fd, action.arg) == -1)
+ ExitWithError(error_fd, "dup2");
+ } else {
+ if (fcntl(action.fd, F_SETFD,
+ fcntl(action.fd, F_GETFD) & ~FD_CLOEXEC) == -1)
----------------
DavidSpickett wrote:
> (One?) reason that couldn't be done with threads was due to stray file descriptors.
If we use this code then exec into a process, does that new process having file descriptors with FD_CLOEXEC not set then create more leaks into any process it might later exec into?
https://github.com/llvm/llvm-project/pull/126935
More information about the lldb-commits
mailing list