extern int launch_p_step_launch(srun_job_t *job, slurm_step_io_fds_t *cio_fds, uint32_t *global_rc, slurm_step_launch_callbacks_t *step_callbacks, opt_t *opt_local) { int rc = 0; pthread_t msg_thread = _spawn_msg_handler(job); aprun_pid = fork(); if (aprun_pid < 0) { error("fork: %m"); return 1; } else if (aprun_pid > 0) { if (waitpid(aprun_pid, &rc, 0) < 0) error("Unable to reap aprun child process"); *global_rc = rc; /* Just because waitpid returns something doesn't mean this function failed so always set it back to 0. */ rc = 0; } else { setpgid(0, 0); _unblock_signals(); /* dup stdio onto our open fds */ if ((dup2(cio_fds->input.fd, 0) == -1) || (dup2(cio_fds->out.fd, 1) == -1) || (dup2(cio_fds->err.fd, 2) == -1)) { error("dup2: %m"); return 1; } execvp(opt_local->argv[0], opt_local->argv); error("execv(aprun) error: %m"); return 1; } _send_step_complete_rpc(job, *global_rc); if (msg_thread) { srun_shutdown = true; pthread_cancel(msg_thread); pthread_join(msg_thread, NULL); } return rc; }
extern int launch_p_step_launch( srun_job_t *job, slurm_step_io_fds_t *cio_fds, uint32_t *global_rc) { pthread_t msg_thread; local_srun_job = job; msg_thread = _spawn_msg_handler(); *global_rc = runjob_launch(opt.argc, opt.argv, cio_fds->in.fd, cio_fds->out.fd, cio_fds->err.fd); _send_step_complete_rpc(*global_rc); if (msg_thread) { srun_shutdown = true; pthread_cancel(msg_thread); pthread_join(msg_thread, NULL); } return 0; }