diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-02 16:14:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-02 16:14:21 +0000 |
commit | 2cbb6fa2186ea20b61d837babcd1015aa8a5004f (patch) | |
tree | 000b2c768659045b97aaefd1576e249be4f57882 /process.c | |
parent | 228bffe5e12cc3cbe9daeeff0bb1a95d89315bff (diff) |
process.c: split pst_message_status from pst_message
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -545,11 +545,18 @@ pst_pid(VALUE st) return rb_attr_get(st, id_pid); } +static VALUE pst_message_status(VALUE str, int status); + static void pst_message(VALUE str, rb_pid_t pid, int status) { - if (pid != (rb_pid_t)-1) - rb_str_catf(str, "pid %ld", (long)pid); + rb_str_catf(str, "pid %ld", (long)pid); + pst_message_status(str, status); +} + +static VALUE +pst_message_status(VALUE str, int status) +{ if (WIFSTOPPED(status)) { int stopsig = WSTOPSIG(status); const char *signame = ruby_signal_name(stopsig); @@ -578,6 +585,7 @@ pst_message(VALUE str, rb_pid_t pid, int status) rb_str_cat2(str, " (core dumped)"); } #endif + return str; } @@ -4092,8 +4100,7 @@ rb_f_system(int argc, VALUE *argv) if (status == EXIT_SUCCESS) return Qtrue; if (eargp->exception) { VALUE str = rb_str_new_cstr("Command failed with"); - pst_message(str, (rb_pid_t)-1, status); - rb_str_cat_cstr(str, ": "); + rb_str_cat_cstr(pst_message_status(str, status), ": "); rb_str_append(str, eargp->invoke.sh.shell_script); rb_exc_raise(rb_exc_new_str(rb_eRuntimeError, str)); } |