Skip to content

Commit 45eb0d0

Browse files
committed
fix(server): preserve backend IPC stdin fd
1 parent ffc9896 commit 45eb0d0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

dflash/src/common/backend_ipc.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ bool BackendIpcProcess::start(const BackendIpcLaunchConfig & cfg) {
6464
return false;
6565
}
6666
if (pid_ == 0) {
67-
::dup2(cmd_pipe[0], STDIN_FILENO);
68-
::close(cmd_pipe[0]);
67+
if (cmd_pipe[0] != STDIN_FILENO && ::dup2(cmd_pipe[0], STDIN_FILENO) < 0) {
68+
std::fprintf(stderr, "backend-ipc dup2 failed: %s\n", std::strerror(errno));
69+
_exit(127);
70+
}
71+
if (cmd_pipe[0] != STDIN_FILENO) ::close(cmd_pipe[0]);
6972
::close(cmd_pipe[1]);
7073
::close(stream_pipe[0]);
7174

0 commit comments

Comments
 (0)