1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* process.c (before_exec, after_exec): change from macro to function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kosaki 2011-05-28 15:24:18 +00:00
parent ed02c4122a
commit bde7a62f91
2 changed files with 31 additions and 13 deletions

View file

@ -1,3 +1,7 @@
Sun May 29 00:22:40 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* process.c (before_exec, after_exec): change from macro to function.
Sat May 28 19:30:17 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* process.c (before_exec, after_exec): change SIGPIPE handler to SIG_DFL

View file

@ -992,33 +992,47 @@ static RETSIGTYPE (*saved_sigpipe_handler)(int) = 0;
# define signal(a,b) posix_signal((a),(b))
#endif
static void save_sigpipe(void)
static void before_exec(void)
{
/*
* signalmask is inherited across exec() and almost system commands don't
* work if signalmask is blocked.
*/
rb_enable_interrupt();
#ifdef SIGPIPE
/*
* Some OS commands don't initialize signal handler properly. Thus we have to
* reset signal handler before exec(). Otherwise, system() and similar child process
* interaction might fail. (e.g. ruby -e "system 'yes | ls'") [ruby-dev:12261]
* Some OS commands don't initialize signal handler properly. Thus we have
* to reset signal handler before exec(). Otherwise, system() and similar
* child process interaction might fail. (e.g. ruby -e "system 'yes | ls'")
* [ruby-dev:12261]
*/
saved_sigpipe_handler = signal(SIGPIPE, SIG_DFL);
#endif
if (!forked_child) {
/*
* On old MacOS X, exec() may return ENOTSUPP if the process have
* multiple threads. Therefore we have to kill internal threads at once.
* [ruby-core: 10583]
*/
rb_thread_stop_timer_thread();
}
}
static void restore_sigpipe(void)
static void after_exec(void)
{
rb_thread_reset_timer_thread();
rb_thread_start_timer_thread();
#ifdef SIGPIPE
signal(SIGPIPE, saved_sigpipe_handler);
#endif
forked_child = 0;
rb_disable_interrupt();
}
/*
* On old MacOS X, exec() may return ENOTSUPP if the process have multiple threads.
* Therefore we have to kill internal threads at once. [ruby-core: 10583]
*/
#define before_exec() \
(rb_enable_interrupt(), save_sigpipe(), (void)(forked_child ? 0 : (rb_thread_stop_timer_thread(), 1)))
#define after_exec() \
(rb_thread_reset_timer_thread(), rb_thread_start_timer_thread(), forked_child = 0, restore_sigpipe(), rb_disable_interrupt())
#define before_fork() before_exec()
#define after_fork() (GET_THREAD()->thrown_errinfo = 0, after_exec())