child_setup_process to stop passing the process

child_setup_process only cares about whether we are in a forked child, not
the entire process structure. Narrow the parameter.
This commit is contained in:
ridiculousfish
2019-07-01 00:47:10 -07:00
parent ca5427865d
commit 8282369f45
3 changed files with 5 additions and 6 deletions

View File

@@ -134,13 +134,12 @@ bool set_child_group(job_t *j, pid_t child_pid) {
return true;
}
int child_setup_process(const job_t *job, process_t *p, const dup2_list_t &dup2s) {
int child_setup_process(const job_t *job, bool is_forked, const dup2_list_t &dup2s) {
// Note we are called in a forked child.
for (const auto &act : dup2s.get_actions()) {
int err = act.target < 0 ? close(act.src) : dup2(act.src, act.target);
if (err < 0) {
// We have a null p if this is for the exec (non-fork) path.
if (p != nullptr) {
if (is_forked) {
debug_safe(4, "redirect_in_child_after_fork failed in child_setup_process");
exit_without_destructors(1);
}