# HG changeset patch # User Yuya Nishihara # Date 2016-01-29 13:42:22 # Node ID 3fc45956c978f5e2fbb7ad912a75fbffc80e8b4a # Parent 550097d01ca3573626ae2eebe6c63b53f6084cde 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. diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c --- a/contrib/chg/chg.c +++ b/contrib/chg/chg.c @@ -241,6 +241,7 @@ static void setupsignalhandler(pid_t pid 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); diff --git a/contrib/chg/util.c b/contrib/chg/util.c --- a/contrib/chg/util.c +++ b/contrib/chg/util.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -63,6 +64,7 @@ int runshellcmd(const char *cmd, const c 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)