================
@@ -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:
...definitely "it's the same picture" if you don't look too deep into it.
* New process is started, and is given some file descriptors.
* It sets CLOEXEC on those.
* It then runs the code this PR is modifying.
* That code clears CLOEXEC from the file descriptor in question, so that it can
live through the execve.
* It execve's into whatever other program.
* From this point on, that file descriptor will never have CLOEXEC set on it,
unless something in this new program does that.
* So we can execve any number of times and the file descriptor will always
survive.
Which sounds vaguely like a "leak" to me, if you do indeed execve multiple
times. But maybe this is the intended behaviour?
https://github.com/llvm/llvm-project/pull/126935
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits