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
This commit is contained in:
parent
228bffe5e1
commit
2cbb6fa218
15
process.c
15
process.c
@ -545,11 +545,18 @@ pst_pid(VALUE st)
|
|||||||
return rb_attr_get(st, id_pid);
|
return rb_attr_get(st, id_pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE pst_message_status(VALUE str, int status);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pst_message(VALUE str, rb_pid_t pid, int status)
|
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)) {
|
if (WIFSTOPPED(status)) {
|
||||||
int stopsig = WSTOPSIG(status);
|
int stopsig = WSTOPSIG(status);
|
||||||
const char *signame = ruby_signal_name(stopsig);
|
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)");
|
rb_str_cat2(str, " (core dumped)");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4092,8 +4100,7 @@ rb_f_system(int argc, VALUE *argv)
|
|||||||
if (status == EXIT_SUCCESS) return Qtrue;
|
if (status == EXIT_SUCCESS) return Qtrue;
|
||||||
if (eargp->exception) {
|
if (eargp->exception) {
|
||||||
VALUE str = rb_str_new_cstr("Command failed with");
|
VALUE str = rb_str_new_cstr("Command failed with");
|
||||||
pst_message(str, (rb_pid_t)-1, status);
|
rb_str_cat_cstr(pst_message_status(str, status), ": ");
|
||||||
rb_str_cat_cstr(str, ": ");
|
|
||||||
rb_str_append(str, eargp->invoke.sh.shell_script);
|
rb_str_append(str, eargp->invoke.sh.shell_script);
|
||||||
rb_exc_raise(rb_exc_new_str(rb_eRuntimeError, str));
|
rb_exc_raise(rb_exc_new_str(rb_eRuntimeError, str));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user