Skip to content

Commit

Permalink
posix_spawn: handle pgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Jan 15, 2024
1 parent 77a318b commit 9a057cd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -4657,7 +4657,22 @@ rb_posix_spawn(struct rb_execarg *eargp)
VALUE envp_str = eargp->envp_str;
char **envp = RTEST(envp_str) ? RB_IMEMO_TMPBUF_PTR(envp_str) : NULL;

int err = posix_spawn(&pid, abspath, NULL, NULL, argv, envp);
int err;

posix_spawnattr_t attr;
posix_spawnattr_init(&attr);

if (eargp->pgroup_given) {
if ((err = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETPGROUP))) {
rb_syserr_fail(err, "posix_spawnattr_setflags");
}

if ((err = posix_spawnattr_setpgroup(&attr, eargp->pgroup_pgid))) {
rb_syserr_fail(err, "posix_spawnattr_setpgroup");
}
}

err = posix_spawn(&pid, abspath, NULL, &attr, argv, envp);
if (err) {
rb_sys_fail(abspath);
}
Expand All @@ -4680,7 +4695,7 @@ rb_spawn_process(struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen)

#if HAVE_POSIX_SPAWN
if (//!eargp->use_shell &&
!eargp->pgroup_given &&
// !eargp->pgroup_given &&
!eargp->umask_given &&
!eargp->unsetenv_others_given &&
!eargp->close_others_given &&
Expand Down

0 comments on commit 9a057cd

Please sign in to comment.