From 2cbb6fa2186ea20b61d837babcd1015aa8a5004f Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 2 Feb 2018 16:14:21 +0000 Subject: [PATCH] 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 --- process.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/process.c b/process.c index c5d4026421..7a4fa3066e 100644 --- a/process.c +++ b/process.c @@ -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)); }