Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use posix spawn #551

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
posix_spawn: handle eargp->fd_dup2_child
  • Loading branch information
byroot committed Jan 24, 2024
commit 52410a136ad51d03e4d9cf3ea87dc968014660d1
14 changes: 14 additions & 0 deletions process.c
Original file line number Diff line number Diff line change
@@ -4725,6 +4725,20 @@ rb_posix_spawn(struct rb_execarg *eargp)
}
}

if (RTEST(eargp->fd_dup2_child)) {
for (long index = 0; index < RARRAY_LEN(eargp->fd_dup2_child); index++) {
VALUE pair = RARRAY_AREF(eargp->fd_dup2_child, index);
VALUE fd = RARRAY_AREF(pair, 0);
VALUE params = RARRAY_AREF(pair, 1);

int new_fd = NUM2INT(params); // TODO: params may not be a FD, may need more massaging.
fprintf(stderr, "posix_spawn_file_actions_adddup2(fops, %d, %d)\n", new_fd, NUM2INT(fd));
if ((err = posix_spawn_file_actions_adddup2(&file_actions, new_fd, NUM2INT(fd)))) {
rb_syserr_fail(err, "posix_spawn_file_actions_adddup2");
}
}
}

if (RTEST(eargp->fd_close)) {
for (long index = 0; index < RARRAY_LEN(eargp->fd_close); index++) {
VALUE pair = RARRAY_AREF(eargp->fd_close, index);