================
@@ -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:
So if the file descriptors are not the same, we want to duplicate what
action.fd refers to, into the file descriptor action.arg. Seems logical, we can
then pass the new file descriptor to the debugee, I think?
(unless this is forking into another part of lldb)
If they are not the same, then we don't want to close action.fd when we next
exec, which is when we fork to run the debugee process? Is this because
action.fd is for example opened by the system, not by lldb or the debugee and
we don't want to interfere with that?
https://github.com/llvm/llvm-project/pull/126935
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits