From 6b87ac68dba3d8967d76233766a174c8a82813e3 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 18 Jul 2006 14:36:15 +0000 Subject: [PATCH] * process.c (rb_f_system): block SIGCHLD during the process execution, like glibc system(3) does. [ruby-talk:202361] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++------ process.c | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 11913b544c..729204ad8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jul 18 22:10:13 2006 Yukihiro Matsumoto + + * process.c (rb_f_system): block SIGCHLD during the process + execution, like glibc system(3) does. [ruby-talk:202361] + Tue Jul 18 23:10:43 2006 NAKAMURA Usaku * win32/win32.c (open_ifs_socket): should not use plain malloc. @@ -7,7 +12,7 @@ Tue Jul 18 23:10:43 2006 NAKAMURA Usaku Tue Jul 18 16:52:29 2006 Yukihiro Matsumoto * eval.c (yield_under_i): argument should be passed in avalue - from. [ruby-dev:29044] + form. [ruby-dev:29044] Tue Jul 18 15:49:42 2006 Yukihiro Matsumoto @@ -29,11 +34,6 @@ Tue Jul 18 15:19:07 2006 NAKAMURA Usaku * missing/vsnprintf.c (BSD__uqtoa): new function to support LLP64. all changes are derived from [ruby-dev:29045] -Tue Jul 18 14:38:40 2006 Yukihiro Matsumoto - - * process.c (rb_f_system): call rb_sys_fail(0) if rb_last_status - is nil. [ruby-talk:202361] - Tue Jul 18 14:03:02 2006 Yukihiro Matsumoto * lib/webrick/httpserver.rb (WEBrick::HTTPServer::unmount): remove diff --git a/process.c b/process.c index 1989f017d9..ae9146a928 100644 --- a/process.c +++ b/process.c @@ -1583,18 +1583,28 @@ rb_spawn(int argc, VALUE *argv) * * */ +#if defined(SIGCLD) && !defined(SIGCHLD) +# define SIGCHLD SIGCLD +#endif + static VALUE rb_f_system(int argc, VALUE *argv) { int status; + RETSIGTYPE (*chfunc)(int); + chfunc = signal(SIGCHLD, SIG_DFL); status = rb_spawn(argc, argv); - if (status == -1) rb_sys_fail(RSTRING(argv[0])->ptr); + if (status > 0) { #if defined(HAVE_FORK) || defined(HAVE_SPAWNV) - rb_syswait(status); - if (NIL_P(rb_last_status)) rb_sys_fail(0); - status = NUM2INT(rb_last_status); + rb_syswait(status); #endif + } + signal(SIGCHLD, chfunc); + if (status < 0) { + rb_sys_fail(RSTRING(argv[0])->ptr); + } + status = NUM2INT(rb_last_status); if (status == EXIT_SUCCESS) return Qtrue; return Qfalse; }