diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-18 14:36:15 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-18 14:36:15 +0000 |
| commit | 3f2010a42d32f2f7da755c5abd5a84b48d29b72a (patch) | |
| tree | 6a69b0ee57e74e5a5cd7af42a192ad9e1d90a8b0 /process.c | |
| parent | a0d73566ce70b720c03ca8aaaa0f6128079b518d (diff) | |
| download | ruby-3f2010a42d32f2f7da755c5abd5a84b48d29b72a.tar.gz ruby-3f2010a42d32f2f7da755c5abd5a84b48d29b72a.tar.xz ruby-3f2010a42d32f2f7da755c5abd5a84b48d29b72a.zip | |
* process.c (rb_f_system): block SIGCHLD during the process
execution, like glibc system(3) does. [ruby-talk:202361]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
| -rw-r--r-- | process.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -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; } |
