Re: [PATCH v2 2/2] connect.c: replace signal() with sigaction()
On 31/05/14 08:58, Jeremiah Mahler wrote: From signal(2) man page: The behavior of signal() varies across UNIX versions, and has also var‐ ied historically across different versions of Linux. Avoid its use: use sigaction(2) instead. Replaced signal() with sigaction() in connect.c Signed-off-by: Jeremiah Mahler jmmah...@gmail.com --- connect.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connect.c b/connect.c index a983d06..b2a33c9 100644 --- a/connect.c +++ b/connect.c @@ -665,11 +665,14 @@ struct child_process *git_connect(int fd[2], const char *url, enum protocol protocol; const char **arg; struct strbuf cmd = STRBUF_INIT; + struct sigaction sa; /* Without this we cannot rely on waitpid() to tell * what happened to our children. */ - signal(SIGCHLD, SIG_DFL); + memset(sa, 0, sizeof(sa)); + sa.sa_handler = SIG_DFL; + sigaction(SIGCHLD, sa, 0); I think this got lost in the wash with v1 but Documentation/CodingGuidelines says to use NULL here instead of 0. protocol = parse_connect_url(url, hostandport, path); if (flags CONNECT_DIAG_URL) { -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/2] connect.c: replace signal() with sigaction()
Chris, On Sat, May 31, 2014 at 10:39:39PM +1200, Chris Packham wrote: On 31/05/14 08:58, Jeremiah Mahler wrote: From signal(2) man page: ... - signal(SIGCHLD, SIG_DFL); + memset(sa, 0, sizeof(sa)); + sa.sa_handler = SIG_DFL; + sigaction(SIGCHLD, sa, 0); I think this got lost in the wash with v1 but Documentation/CodingGuidelines says to use NULL here instead of 0. Got it. Will be in to the next revision. sigaction(SIGCHLD, sa, NULL); Thanks, -- Jeremiah Mahler jmmah...@gmail.com http://github.com/jmahler -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/2] connect.c: replace signal() with sigaction()
From signal(2) man page: The behavior of signal() varies across UNIX versions, and has also var‐ ied historically across different versions of Linux. Avoid its use: use sigaction(2) instead. Replaced signal() with sigaction() in connect.c Signed-off-by: Jeremiah Mahler jmmah...@gmail.com --- connect.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connect.c b/connect.c index a983d06..b2a33c9 100644 --- a/connect.c +++ b/connect.c @@ -665,11 +665,14 @@ struct child_process *git_connect(int fd[2], const char *url, enum protocol protocol; const char **arg; struct strbuf cmd = STRBUF_INIT; + struct sigaction sa; /* Without this we cannot rely on waitpid() to tell * what happened to our children. */ - signal(SIGCHLD, SIG_DFL); + memset(sa, 0, sizeof(sa)); + sa.sa_handler = SIG_DFL; + sigaction(SIGCHLD, sa, 0); protocol = parse_connect_url(url, hostandport, path); if (flags CONNECT_DIAG_URL) { -- 2.0.0.2.g1d11d5d -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/2] connect.c: replace signal() with sigaction()
Jeremiah Mahler jmmah...@gmail.com writes: From signal(2) man page: The behavior of signal() varies across UNIX versions, and has also var‐ ied historically across different versions of Linux. Avoid its use: use sigaction(2) instead. I don't think this matters for SIG_DFL or SIG_IGN. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 And now for something completely different. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html