1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Use more verbose status in error messages

of `system` with `exception: true` like `Process::Status#inspect`
[Feature #14386] [ruby-core:85013]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kazu 2018-02-02 11:03:22 +00:00
parent 49e801c1c7
commit 1659a1660c

View file

@ -548,7 +548,8 @@ pst_pid(VALUE st)
static void
pst_message(VALUE str, rb_pid_t pid, int status)
{
rb_str_catf(str, "pid %ld", (long)pid);
if (pid != (rb_pid_t)-1)
rb_str_catf(str, "pid %ld", (long)pid);
if (WIFSTOPPED(status)) {
int stopsig = WSTOPSIG(status);
const char *signame = ruby_signal_name(stopsig);
@ -4090,8 +4091,10 @@ rb_f_system(int argc, VALUE *argv)
status = PST2INT(rb_last_status_get());
if (status == EXIT_SUCCESS) return Qtrue;
if (eargp->exception) {
rb_raise(rb_eRuntimeError, "Command failed with status (%d): %s",
WEXITSTATUS(status), RSTRING_PTR(eargp->invoke.sh.shell_script));
VALUE str = rb_str_buf_new(0);
pst_message(str, (rb_pid_t)-1, status);
rb_raise(rb_eRuntimeError, "Command failed with%"PRIsVALUE": %s",
str, RSTRING_PTR(eargp->invoke.sh.shell_script));
}
else {
return Qfalse;