* process.c (struct child_handler_disabler_state): cancelstate field

added.
  (disable_child_handler_before_fork): Record cancelstate.
  (disable_child_handler_fork_parent): Restore cancelstate.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2014-09-06 11:20:08 +00:00
Родитель 3de392def9
Коммит 42becbddc2
2 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Sat Sep 6 20:19:16 2014 Tanaka Akira <akr@fsij.org>
* process.c (struct child_handler_disabler_state): cancelstate field
added.
(disable_child_handler_before_fork): Record cancelstate.
(disable_child_handler_fork_parent): Restore cancelstate.
Sat Sep 6 19:27:10 2014 Tanaka Akira <akr@fsij.org>
* process.c (struct child_handler_disabler_state): Defined.

Просмотреть файл

@ -3382,6 +3382,7 @@ has_privilege(void)
struct child_handler_disabler_state
{
sigset_t sigmask;
int cancelstate;
};
static void
@ -3399,6 +3400,12 @@ disable_child_handler_before_fork(struct child_handler_disabler_state *old)
errno = ret;
rb_sys_fail("pthread_sigmask");
}
ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old->cancelstate);
if (ret != 0) {
errno = ret;
rb_sys_fail("pthread_setcancelstate");
}
}
static void
@ -3406,6 +3413,12 @@ disable_child_handler_fork_parent(struct child_handler_disabler_state *old)
{
int ret;
ret = pthread_setcancelstate(old->cancelstate, NULL);
if (ret != 0) {
errno = ret;
rb_sys_fail("pthread_setcancelstate");
}
ret = pthread_sigmask(SIG_SETMASK, &old->sigmask, NULL); /* not async-signal-safe */
if (ret != 0) {
errno = ret;