Skip to content

Commit f91b8c9

Browse files
committed
fix posix.c: dup2 call (delegate to dup3 only on linux and if fd is not inheritable)
1 parent 4c36b84 commit f91b8c9

File tree

1 file changed

+4
-3
lines changed
  • graalpython/com.oracle.graal.python.cext/posix

1 file changed

+4
-3
lines changed

graalpython/com.oracle.graal.python.cext/posix/posix.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ int32_t call_dup(int32_t fd) {
130130

131131
int32_t call_dup2(int32_t oldfd, int32_t newfd, int32_t inheritable) {
132132
#ifdef __gnu_linux__
133-
return dup3(oldfd, newfd, inheritable ? 0 : O_CLOEXEC);
134-
#else
133+
if (!inheritable) {
134+
return dup3(oldfd, newfd, O_CLOEXEC);
135+
}
136+
#endif
135137
int res = dup2(oldfd, newfd);
136138
if (res < 0) {
137139
return res;
@@ -143,7 +145,6 @@ int32_t call_dup2(int32_t oldfd, int32_t newfd, int32_t inheritable) {
143145
}
144146
}
145147
return res;
146-
#endif
147148
}
148149

149150
int32_t call_pipe2(int32_t *pipefd) {

0 commit comments

Comments
 (0)