Skip to content

Commit d69a6f6

Browse files
committed
posix_spawn: handle eargp->fd_dup2_child
1 parent 5b4f8a8 commit d69a6f6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

process.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4725,6 +4725,20 @@ rb_posix_spawn(struct rb_execarg *eargp)
47254725
}
47264726
}
47274727

4728+
if (RTEST(eargp->fd_dup2_child)) {
4729+
for (long index = 0; index < RARRAY_LEN(eargp->fd_dup2_child); index++) {
4730+
VALUE pair = RARRAY_AREF(eargp->fd_dup2_child, index);
4731+
VALUE fd = RARRAY_AREF(pair, 0);
4732+
VALUE params = RARRAY_AREF(pair, 1);
4733+
4734+
int new_fd = NUM2INT(params); // TODO: params may not be a FD, may need more massaging.
4735+
fprintf(stderr, "posix_spawn_file_actions_adddup2(fops, %d, %d)\n", new_fd, NUM2INT(fd));
4736+
if ((err = posix_spawn_file_actions_adddup2(&file_actions, new_fd, NUM2INT(fd)))) {
4737+
rb_syserr_fail(err, "posix_spawn_file_actions_adddup2");
4738+
}
4739+
}
4740+
}
4741+
47284742
if (RTEST(eargp->fd_close)) {
47294743
for (long index = 0; index < RARRAY_LEN(eargp->fd_close); index++) {
47304744
VALUE pair = RARRAY_AREF(eargp->fd_close, index);

0 commit comments

Comments
 (0)