ruby-changes:50048
From: nobu <ko1@a...>
Date: Sat, 3 Feb 2018 01:14:26 +0900 (JST)
Subject: [ruby-changes:50048] nobu:r62166 (trunk): process.c: split pst_message_status from pst_message
nobu 2018-02-03 01:14:21 +0900 (Sat, 03 Feb 2018) New Revision: 62166 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62166 Log: process.c: split pst_message_status from pst_message Modified files: trunk/process.c Index: process.c =================================================================== --- process.c (revision 62165) +++ process.c (revision 62166) @@ -545,11 +545,18 @@ pst_pid(VALUE st) https://github.com/ruby/ruby/blob/trunk/process.c#L545 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 https://github.com/ruby/ruby/blob/trunk/process.c#L585 rb_str_cat2(str, " (core dumped)"); } #endif + return str; } @@ -4092,8 +4100,7 @@ rb_f_system(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L4100 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)); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/