Mercurial > hg
changeset 28084:3fc45956c978
chg: initialize sigaction fields more reliably
It seems calling memset() and sigemptyset() is common pattern to initialize
sigaction. And strictly speaking, sigset_t must be initialized by sigemptyset()
or sigfillset(). I saw git and uwsgi do that way, so let's follow them.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 29 Jan 2016 22:42:22 +0900 |
parents | 550097d01ca3 |
children | c0d1bf1b26b7 |
files | contrib/chg/chg.c contrib/chg/util.c |
diffstat | 2 files changed, 3 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/chg/chg.c Fri Feb 12 06:25:05 2016 -0800 +++ b/contrib/chg/chg.c Fri Jan 29 22:42:22 2016 +0900 @@ -241,6 +241,7 @@ memset(&sa, 0, sizeof(sa)); sa.sa_handler = forwardsignal; sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); sigaction(SIGHUP, &sa, NULL); sigaction(SIGINT, &sa, NULL);
--- a/contrib/chg/util.c Fri Feb 12 06:25:05 2016 -0800 +++ b/contrib/chg/util.c Fri Jan 29 22:42:22 2016 +0900 @@ -11,6 +11,7 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> @@ -63,6 +64,7 @@ sigset_t oldmask; /* block or mask signals just as system() does */ + memset(&newsa, 0, sizeof(newsa)); newsa.sa_handler = SIG_IGN; newsa.sa_flags = 0; if (sigemptyset(&newsa.sa_mask) < 0)