diff -r 3fc45956c978 -r c0d1bf1b26b7 contrib/chg/chg.c --- a/contrib/chg/chg.c Fri Jan 29 22:42:22 2016 +0900 +++ b/contrib/chg/chg.c Fri Jan 29 22:52:16 2016 +0900 @@ -241,14 +241,22 @@ memset(&sa, 0, sizeof(sa)); sa.sa_handler = forwardsignal; sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); + if (sigemptyset(&sa.sa_mask) < 0) + goto error; - sigaction(SIGHUP, &sa, NULL); - sigaction(SIGINT, &sa, NULL); + if (sigaction(SIGHUP, &sa, NULL) < 0) + goto error; + if (sigaction(SIGINT, &sa, NULL) < 0) + goto error; /* terminate frontend by double SIGTERM in case of server freeze */ sa.sa_flags |= SA_RESETHAND; - sigaction(SIGTERM, &sa, NULL); + if (sigaction(SIGTERM, &sa, NULL) < 0) + goto error; + return; + +error: + abortmsg("failed to set up signal handlers (errno = %d)", errno); } /* This implementation is based on hgext/pager.py (pre 369741ef7253) */