ruby-changes:35354
From: akr <ko1@a...>
Date: Sat, 6 Sep 2014 19:28:08 +0900 (JST)
Subject: [ruby-changes:35354] akr:r47436 (trunk): * process.c (struct child_handler_disabler_state): Defined.
akr 2014-09-06 19:27:54 +0900 (Sat, 06 Sep 2014) New Revision: 47436 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47436 Log: * process.c (struct child_handler_disabler_state): Defined. Modified files: trunk/ChangeLog trunk/process.c Index: ChangeLog =================================================================== --- ChangeLog (revision 47435) +++ ChangeLog (revision 47436) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Sep 6 19:27:10 2014 Tanaka Akira <akr@f...> + + * process.c (struct child_handler_disabler_state): Defined. + Sat Sep 6 18:31:32 2014 SHIBATA Hiroshi <shibata.hiroshi@g...> * lib/rake.rb, lib/rake/*, test/rake/*: Update latest rake master(e47d023) Index: process.c =================================================================== --- process.c (revision 47435) +++ process.c (revision 47436) @@ -3379,8 +3379,13 @@ has_privilege(void) https://github.com/ruby/ruby/blob/trunk/process.c#L3379 return 0; } +struct child_handler_disabler_state +{ + sigset_t sigmask; +}; + static void -disable_child_handler_before_fork(sigset_t *oldset) +disable_child_handler_before_fork(struct child_handler_disabler_state *old) { int ret; sigset_t all; @@ -3389,7 +3394,7 @@ disable_child_handler_before_fork(sigset https://github.com/ruby/ruby/blob/trunk/process.c#L3394 if (ret == -1) rb_sys_fail("sigfillset"); - ret = pthread_sigmask(SIG_SETMASK, &all, oldset); /* not async-signal-safe */ + ret = pthread_sigmask(SIG_SETMASK, &all, &old->sigmask); /* not async-signal-safe */ if (ret != 0) { errno = ret; rb_sys_fail("pthread_sigmask"); @@ -3397,11 +3402,11 @@ disable_child_handler_before_fork(sigset https://github.com/ruby/ruby/blob/trunk/process.c#L3402 } static void -disable_child_handler_fork_parent(sigset_t *oldset) +disable_child_handler_fork_parent(struct child_handler_disabler_state *old) { int ret; - ret = pthread_sigmask(SIG_SETMASK, oldset, NULL); /* not async-signal-safe */ + ret = pthread_sigmask(SIG_SETMASK, &old->sigmask, NULL); /* not async-signal-safe */ if (ret != 0) { errno = ret; rb_sys_fail("pthread_sigmask"); @@ -3410,7 +3415,7 @@ disable_child_handler_fork_parent(sigset https://github.com/ruby/ruby/blob/trunk/process.c#L3415 /* This function should be async-signal-safe. Actually it is. */ static int -disable_child_handler_fork_child(sigset_t *oldset, char *errmsg, size_t errmsg_buflen) +disable_child_handler_fork_child(struct child_handler_disabler_state *old, char *errmsg, size_t errmsg_buflen) { int sig; int ret; @@ -3451,7 +3456,7 @@ disable_child_handler_fork_child(sigset_ https://github.com/ruby/ruby/blob/trunk/process.c#L3456 } } - ret = sigprocmask(SIG_SETMASK, oldset, NULL); /* async-signal-safe */ + ret = sigprocmask(SIG_SETMASK, &old->sigmask, NULL); /* async-signal-safe */ if (ret != 0) { ERRMSG("sigprocmask"); return -1; @@ -3466,11 +3471,11 @@ retry_fork_async_signal_safe(int *status https://github.com/ruby/ruby/blob/trunk/process.c#L3471 { rb_pid_t pid; volatile int try_gc = 1; - sigset_t oldsigmask; + struct child_handler_disabler_state old; while (1) { prefork(); - disable_child_handler_before_fork(&oldsigmask); + disable_child_handler_before_fork(&old); #ifdef HAVE_WORKING_VFORK if (!has_privilege()) pid = vfork(); @@ -3482,7 +3487,7 @@ retry_fork_async_signal_safe(int *status https://github.com/ruby/ruby/blob/trunk/process.c#L3487 if (pid == 0) {/* fork succeed, child process */ int ret; close(ep[0]); - ret = disable_child_handler_fork_child(&oldsigmask, errmsg, errmsg_buflen); /* async-signal-safe */ + ret = disable_child_handler_fork_child(&old, errmsg, errmsg_buflen); /* async-signal-safe */ if (ret == 0) { ret = chfunc(charg, errmsg, errmsg_buflen); if (!ret) _exit(EXIT_SUCCESS); @@ -3494,7 +3499,7 @@ retry_fork_async_signal_safe(int *status https://github.com/ruby/ruby/blob/trunk/process.c#L3499 _exit(127); #endif } - preserving_errno(disable_child_handler_fork_parent(&oldsigmask)); + preserving_errno(disable_child_handler_fork_parent(&old)); if (0 < pid) /* fork succeed, parent process */ return pid; /* fork failed */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/