Skip to content

Commit

Permalink
signal.c: relax installation failure
Browse files Browse the repository at this point in the history
* signal.c (install_sighandler): ignore failure at unreserved
  signals.  e.g., SIGUSR2 fails under valgrind.

* signal.c (install_sighandler_fail): refine [BUG] message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jun 8, 2017
1 parent 269b795 commit a2f1c07
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,11 @@ ruby_signal(int signum, sighandler_t handler)
return SIG_ERR;
}
if (old.sa_flags & SA_SIGINFO)
return (sighandler_t)old.sa_sigaction;
handler = (sighandler_t)old.sa_sigaction;
else
return old.sa_handler;
handler = old.sa_handler;
ASSUME(handler != SIG_ERR);
return handler;
}

sighandler_t
Expand Down Expand Up @@ -1384,6 +1386,7 @@ sig_list(void)
return h;
}

#define install_sighandler_fail(signum) rb_bug("failed to install "signum" handler")
static int
install_sighandler(int signum, sighandler_t handler)
{
Expand All @@ -1398,7 +1401,9 @@ install_sighandler(int signum, sighandler_t handler)
return 0;
}
#ifndef __native_client__
# define install_sighandler(signum, handler) (install_sighandler(signum, handler) ? rb_bug(#signum) : (void)0)
# define install_sighandler(signum, handler) \
(install_sighandler(signum, handler) && reserved_signal_p(signum) ? \
install_sighandler_fail(#signum) : (void)0)
#endif

#if defined(SIGCLD) || defined(SIGCHLD)
Expand All @@ -1418,7 +1423,8 @@ init_sigchld(int sig)
return 0;
}
# ifndef __native_client__
# define init_sigchld(signum) (init_sigchld(signum) ? rb_bug(#signum) : (void)0)
# define init_sigchld(signum) \
(init_sigchld(signum) ? install_sighandler_fail(#signum) : (void)0)
# endif
#endif

Expand Down

0 comments on commit a2f1c07

Please sign in to comment.