This is version 3 of the patch set to convert signal(2) to sigaction(2)
(previous discussion [1]).
[1]: http://marc.info/?l=git&m=140148352416926&w=2
Changes in this revision include:
- Using NULL pointers instead of 0 as per the
Documentation/CodingGuidlines pointed out by Chris Packham.
sigaction(SIGCHLD, &sa, NULL);
- Conversion of all remaining files which used signal().
- sigchain.c required the most changes. Both the old signal handler
was used and the return value from signal() was being checked.
signal() would return the previous error handler which would be
SIG_ERR if an error occurred. sigaction() just returns -1 in this
case.
Jeremiah Mahler (9):
compat/mingw.c: expand MinGW support for sigaction
connect.c: replace signal() with sigaction()
progress.c: replace signal() with sigaction()
write_or_die.c: replace signal() with sigaction()
daemon.c: replace signal() with sigaction()
builtin/log.c: replace signal() with sigaction()
builtin/merge-index.c: replace signal() with sigaction()
builtin/verify-tag.c: replace signal() with sigaction()
sigchain.c: replace signal() with sigaction()
builtin/log.c | 6 +++++-
builtin/merge-index.c | 5 ++++-
builtin/verify-tag.c | 5 ++++-
compat/mingw.c | 9 +++++----
connect.c | 5 ++++-
daemon.c | 16 +++++++++++++---
progress.c | 6 +++++-
sigchain.c | 14 +++++++++++---
write_or_die.c | 6 +++++-
9 files changed, 56 insertions(+), 16 deletions(-)
--
2.0.0.8.g7bf6e1f.dirty
Due to portability issues across UNIX versions sigaction(2) should be used
instead of signal(2).
From the 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.
Unfortunately MinGW under Windows has limited support for signal and no
support for sigaction. And this prevents sigaction from being used across
the entire Git project.
In compat/mingw.c there is a faux sigaction function but it only supports
SIGALARM. Hence the need for continuing to use signal() in other cases.
This patch expands the faux sigaction function so that it calls signal in
cases other than SIGALRM. Now sigaction can be used across the entire Git
project and MinGW will still work with signal as it did before.
Signed-off-by: Jeremiah Mahler <redacted>
---
compat/mingw.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
From the 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 <redacted>
---
connect.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
@@ -665,11 +665,14 @@ struct child_process *git_connect(int fd[2], const char *url,enumprotocolprotocol;constchar**arg;structstrbufcmd=STRBUF_INIT;+structsigactionsa;/* Without this we cannot rely on waitpid() to tell*whathappenedtoourchildren.*/-signal(SIGCHLD,SIG_DFL);+memset(&sa,0,sizeof(sa));+sa.sa_handler=SIG_DFL;+sigaction(SIGCHLD,&sa,NULL);protocol=parse_connect_url(url,&hostandport,&path);if(flags&CONNECT_DIAG_URL){
From the 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 write_or_die.c
Signed-off-by: Jeremiah Mahler <redacted>
---
write_or_die.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
@@ -2,8 +2,12 @@staticvoidcheck_pipe(interr){+structsigactionsa;+if(err==EPIPE){-signal(SIGPIPE,SIG_DFL);+memset(&sa,0,sizeof(sa));+sa.sa_handler=SIG_DFL;+sigaction(SIGPIPE,&sa,NULL);raise(SIGPIPE);/* Should never happen, but just in case... */exit(141);
From the 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 progress.c
Signed-off-by: Jeremiah Mahler <redacted>
---
progress.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
From the 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 daemon.c
Signed-off-by: Jeremiah Mahler <redacted>
---
daemon.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
From the 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 builtin/log.c
Signed-off-by: Jeremiah Mahler <redacted>
---
builtin/log.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
From the 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 builtin/merge-index.c
Signed-off-by: Jeremiah Mahler <redacted>
---
builtin/merge-index.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
@@ -68,11 +68,14 @@ static void merge_all(void)intcmd_merge_index(intargc,constchar**argv,constchar*prefix){inti,force_file=0;+structsigactionsa;/* Without this we cannot rely on waitpid() to tell*whathappenedtoourchildren.*/-signal(SIGCHLD,SIG_DFL);+memset(&sa,0,sizeof(sa));+sa.sa_handler=SIG_DFL;+sigaction(SIGCHLD,&sa,NULL);if(argc<3)usage("git merge-index [-o] [-q] <merge-program> (-a | [--] <filename>*)");
From the 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 builtin/verify-tag.c
Signed-off-by: Jeremiah Mahler <redacted>
---
builtin/verify-tag.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
@@ -73,6 +73,7 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)OPT__VERBOSE(&verbose,N_("print tag contents")),OPT_END()};+structsigactionsa;git_config(git_verify_tag_config,NULL);
@@ -83,7 +84,9 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)/* sometimes the program was terminated because this signal*wasreceivedintheprocessofwritingthegpginput:*/-signal(SIGPIPE,SIG_IGN);+memset(&sa,0,sizeof(sa));+sa.sa_handler=SIG_IGN;+sigaction(SIGPIPE,&sa,NULL);while(i<argc)if(verify_tag(argv[i++],verbose))had_error=1;
From the 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 sigchain.c
Signed-off-by: Jeremiah Mahler <redacted>
---
sigchain.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
From: Johannes Sixt <hidden> Date: 2016-06-15 23:01:26
Am 6/1/2014 20:10, schrieb Jeremiah Mahler:
quoted hunk
Due to portability issues across UNIX versions sigaction(2) should be used
instead of signal(2).
quoted
From the 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.
Unfortunately MinGW under Windows has limited support for signal and no
support for sigaction. And this prevents sigaction from being used across
the entire Git project.
In compat/mingw.c there is a faux sigaction function but it only supports
SIGALARM. Hence the need for continuing to use signal() in other cases.
This patch expands the faux sigaction function so that it calls signal in
cases other than SIGALRM. Now sigaction can be used across the entire Git
project and MinGW will still work with signal as it did before.
Signed-off-by: Jeremiah Mahler <redacted>
---
compat/mingw.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
From: Johannes Sixt <hidden> Date: 2016-06-15 23:01:27
Am 6/1/2014 20:10, schrieb Jeremiah Mahler:
This is version 3 of the patch set to convert signal(2) to sigaction(2)
(previous discussion [1]).
[1]: http://marc.info/?l=git&m=140148352416926&w=2
Changes in this revision include:
- Using NULL pointers instead of 0 as per the
Documentation/CodingGuidlines pointed out by Chris Packham.
sigaction(SIGCHLD, &sa, NULL);
- Conversion of all remaining files which used signal().
- sigchain.c required the most changes. Both the old signal handler
was used and the return value from signal() was being checked.
signal() would return the previous error handler which would be
SIG_ERR if an error occurred. sigaction() just returns -1 in this
case.
Jeremiah Mahler (9):
compat/mingw.c: expand MinGW support for sigaction
connect.c: replace signal() with sigaction()
progress.c: replace signal() with sigaction()
write_or_die.c: replace signal() with sigaction()
daemon.c: replace signal() with sigaction()
builtin/log.c: replace signal() with sigaction()
builtin/merge-index.c: replace signal() with sigaction()
builtin/verify-tag.c: replace signal() with sigaction()
sigchain.c: replace signal() with sigaction()
The series without patch 9/9 works on Windows so far.
Without patch patch 9/9 and a more complete implementation of sigaction in
compat/mingw.c the series misses its goal. But even if you complete it, it
is IMHO only code churn without practical merits.
-- Hannes
Hannes,
On Mon, Jun 02, 2014 at 01:28:25PM +0200, Johannes Sixt wrote:
Am 6/1/2014 20:10, schrieb Jeremiah Mahler:
quoted
This is version 3 of the patch set to convert signal(2) to sigaction(2)
(previous discussion [1]).
...
quoted
sigchain.c: replace signal() with sigaction()
The series without patch 9/9 works on Windows so far.
Without patch patch 9/9 and a more complete implementation of sigaction in
compat/mingw.c the series misses its goal. But even if you complete it, it
is IMHO only code churn without practical merits.
-- Hannes
You are right, I missed the case where the old signal was used, as is
done in sigchain.c. Sorry about that.
Thanks again for looking at my patch.
--
Jeremiah Mahler
jmmahler@gmail.com
http://github.com/jmahler