Skip to content

Commit 5546928

Browse files
committed
Merge branch 'wip/T247' of github.com:bgamari/process
2 parents d7bafbb + f5e10c4 commit 5546928

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cbits/posix/fork_exec.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ setup_std_handle_fork(int fd,
6969
return 0;
7070

7171
case STD_HANDLE_USE_FD:
72-
if (dup2(b->use_fd, fd) == -1) {
73-
child_failed(pipe, "dup2");
72+
// N.B. POSIX specifies that dup2(x,x) should be a no-op, but
73+
// naturally Apple ignores this and rather fails in posix_spawn on Big
74+
// Sur.
75+
if (b->use_fd != fd) {
76+
if (dup2(b->use_fd, fd) == -1) {
77+
child_failed(pipe, "dup2");
78+
}
7479
}
7580
return 0;
7681

0 commit comments

Comments
 (0)