From 42becbddc24ed347d67e479cccfabcc3404b24ae Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 6 Sep 2014 11:20:08 +0000 Subject: [PATCH] * 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 --- ChangeLog | 7 +++++++ process.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2556f69de7..af9cb238bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Sep 6 20:19:16 2014 Tanaka Akira + + * 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 * process.c (struct child_handler_disabler_state): Defined. diff --git a/process.c b/process.c index 3733cd03b0..3d1d0cd458 100644 --- a/process.c +++ b/process.c @@ -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;