diff options
author | Samuel Williams <[email protected]> | 2021-09-22 00:02:14 +1200 |
---|---|---|
committer | Samuel Williams <[email protected]> | 2021-09-22 18:50:26 +1200 |
commit | bf3e3148525b8f83be9b7374ae41b07cc73f5052 (patch) | |
tree | e84a0e6f53f63111661e8661e4ff8ae356f7383e /process.c | |
parent | 7db021f83bc68420746835bb92fce9a5d5a93d9b (diff) |
Rework order of operations to better handle last_status.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4595
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -4203,7 +4203,7 @@ retry_fork_async_signal_safe(struct rb_process_status *status, int *ep, _exit(127); #endif } - err = errno; + err = errno; waitpid_lock = waitpid_lock_init; if (waitpid_lock) { if (pid > 0 && w != WAITPID_LOCK_ONLY) { @@ -4768,14 +4768,15 @@ rb_f_system(int argc, VALUE *argv, VALUE _) VALUE execarg_obj = rb_execarg_new(argc, argv, TRUE, TRUE); struct rb_execarg *eargp = rb_execarg_get(execarg_obj); - struct rb_process_status status; + struct rb_process_status status = {0}; eargp->status = &status; - /* may be different from waitpid_state.pid on exec failure */ - rb_pid_t pid = rb_execarg_spawn(execarg_obj, 0, 0); - rb_last_status_clear(); + // This function can set the thread's last status. + // May be different from waitpid_state.pid on exec failure. + rb_pid_t pid = rb_execarg_spawn(execarg_obj, 0, 0); + if (pid > 0) { VALUE status = rb_process_status_wait(pid, 0); struct rb_process_status *data = RTYPEDDATA_DATA(status); @@ -4813,10 +4814,6 @@ rb_f_system(int argc, VALUE *argv, VALUE _) RB_GC_GUARD(status); } - if (status.pid > 0) { - GET_THREAD()->last_status = rb_process_status_new(status.pid, status.status, status.error); - } - if (eargp->exception) { VALUE command = eargp->invoke.sh.shell_script; RB_GC_GUARD(execarg_obj); |