Skip to content

Commit 516dc42

Browse files
committed
Use dup2 to remove warnings and explicit the intent
1 parent 0b50284 commit 516dc42

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

vm/boostenv/main/modos.hh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,8 @@ public:
885885
raiseLastOSError(vm, "open");
886886
}
887887

888-
dup(dn); // stdout
889-
dup(dn); // stderr
888+
dup2(dn, 1); // stdout
889+
dup2(dn, 2); // stderr
890890
}
891891
#endif
892892

@@ -1090,9 +1090,9 @@ public:
10901090
close(i);
10911091
}
10921092
}
1093-
dup(socketHandle);
1094-
dup(socketHandle);
1095-
dup(socketHandle);
1093+
dup2(socketHandle, 0); // stdin
1094+
dup2(socketHandle, 1); // stdout
1095+
dup2(socketHandle, 2); // stderr
10961096

10971097
auto c_executable = executable.string;
10981098
auto c_argv = new char*[argc+1];

0 commit comments

Comments
 (0)