diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-09-29 02:44:49 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-09-29 02:44:49 +0000 |
commit | 4699b4afbb8e0fd96957de6dd6f23ecbe2a1bdd0 (patch) | |
tree | 422a2ee7d53697aad502fbb7b2490856c0b7d16a /process.c | |
parent | b2cf59aa1cbfb8109f0f2579427159c47f93e6eb (diff) |
* eval.c (rb_thread_atfork): wrong format specifier.
[ruby-dev:21428]
* process.c (pst_inspect): better description.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 44 |
1 files changed, 43 insertions, 1 deletions
@@ -145,6 +145,48 @@ pst_pid(st) } static VALUE +pst_inspect(st) + VALUE st; +{ + VALUE pid; + int status; + VALUE str; + char buf[256]; + + pid = pst_pid(st); + status = NUM2INT(st); + + snprintf(buf, sizeof(buf), "#<%s: pid=%ld", rb_class2name(CLASS_OF(st)), NUM2LONG(pid)); + str = rb_str_new2(buf); + if (WIFSTOPPED(status)) { + snprintf(buf, sizeof(buf), ",stopped(%d)", WSTOPSIG(status)); + rb_str_cat2(str, buf); + } + if (WIFSIGNALED(status)) { + int termsig = WTERMSIG(status); + char *signame = ruby_signal_name(termsig); + if (signame) { + snprintf(buf, sizeof(buf), ",signaled(SIG%s=%d)", signame, termsig); + } + else { + snprintf(buf, sizeof(buf), ",signaled(%d)", termsig); + } + rb_str_cat2(str, buf); + } + if (WIFEXITED(status)) { + snprintf(buf, sizeof(buf), ",exited(%d)", WEXITSTATUS(status)); + rb_str_cat2(str, buf); + } +#ifdef WCOREDUMP + if (WCOREDUMP(status)) { + rb_str_cat2(str, ",coredumped"); + } +#endif + rb_str_cat2(str, ">"); + return str; +} + +static VALUE pst_equal(st1, st2) VALUE st1, st2; { @@ -2347,7 +2389,7 @@ Init_process() rb_define_method(rb_cProcStatus, "to_i", pst_to_i, 0); rb_define_method(rb_cProcStatus, "to_int", pst_to_i, 0); rb_define_method(rb_cProcStatus, "to_s", pst_to_s, 0); - rb_define_method(rb_cProcStatus, "inspect", pst_to_s, 0); + rb_define_method(rb_cProcStatus, "inspect", pst_inspect, 0); rb_define_method(rb_cProcStatus, "pid", pst_pid, 0); |