ruby-changes:35355
From: akr <ko1@a...>
Date: Sat, 6 Sep 2014 20:20:20 +0900 (JST)
Subject: [ruby-changes:35355] akr:r47437 (trunk): * process.c (struct child_handler_disabler_state): cancelstate field
akr 2014-09-06 20:20:08 +0900 (Sat, 06 Sep 2014) New Revision: 47437 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47437 Log: * process.c (struct child_handler_disabler_state): cancelstate field added. (disable_child_handler_before_fork): Record cancelstate. (disable_child_handler_fork_parent): Restore cancelstate. Modified files: trunk/ChangeLog trunk/process.c Index: ChangeLog =================================================================== --- ChangeLog (revision 47436) +++ ChangeLog (revision 47437) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Sep 6 20:19:16 2014 Tanaka Akira <akr@f...> + + * 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@f...> * process.c (struct child_handler_disabler_state): Defined. Index: process.c =================================================================== --- process.c (revision 47436) +++ process.c (revision 47437) @@ -3382,6 +3382,7 @@ has_privilege(void) https://github.com/ruby/ruby/blob/trunk/process.c#L3382 struct child_handler_disabler_state { sigset_t sigmask; + int cancelstate; }; static void @@ -3399,6 +3400,12 @@ disable_child_handler_before_fork(struct https://github.com/ruby/ruby/blob/trunk/process.c#L3400 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 https://github.com/ruby/ruby/blob/trunk/process.c#L3413 { 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; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/