summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-02 11:03:22 +0000
committerkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-02 11:03:22 +0000
commit1659a1660ce32c7ab926586a270c38ddfd0764e4 (patch)
tree9a2841ad630a7e35b8e6c6cfbf1e8411f18b3f7c /process.c
parent49e801c1c77a898469b74b5f63d54665386119cf (diff)
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
Diffstat (limited to 'process.c')
-rw-r--r--process.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/process.c b/process.c
index 8b8268e9f1..6ad9216564 100644
--- a/process.c
+++ b/process.c
@@ -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;