[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] gawk bug report: SIGPIPE reset not effective
From: |
Ian Jackson |
Subject: |
Re: [bug-gawk] gawk bug report: SIGPIPE reset not effective |
Date: |
Mon, 9 May 2016 14:51:42 +0100 |
address@hidden writes ("Re: [bug-gawk] gawk bug report: SIGPIPE reset not
effective"):
> Thanks for your note. You did not include your proposed patch; please
> send it on and I'll try to review.
Sorry - here you go.
Thanks,
Ian.
diff --git a/builtin.c b/builtin.c
index a62437a..2f79c1a 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2080,9 +2080,15 @@ do_system(int nargs)
cmd[tmp->stlen] = '\0';
os_restore_mode(fileno(stdin));
+#ifdef SIGPIPE
+ signal(SIGPIPE, SIG_DFL);
+#endif /*SIGPIPE*/
ret = system(cmd);
if (ret != -1)
ret = WEXITSTATUS(ret);
+#ifdef SIGPIPE
+ signal(SIGPIPE, SIG_IGN);
+#endif /*SIGPIPE*/
if ((BINMODE & BINMODE_INPUT) != 0)
os_setbinmode(fileno(stdin), O_BINARY);
diff --git a/debian/changelog b/debian/changelog
index e208fd7..7d0ee06 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+gawk (1:4.1.3+dfsg-0.1+iwj) UNRELEASED; urgency=medium
+
+ * Restore SIGPIPE across popen and system.
+
+ -- Ian Jackson <address@hidden> Sun, 08 May 2016 19:02:25 +0100
+
gawk (1:4.1.3+dfsg-0.1) unstable; urgency=medium
* Non-maintainer upload.
diff --git a/io.c b/io.c
index 2344c2a..ce04f70 100644
--- a/io.c
+++ b/io.c
@@ -2387,7 +2387,13 @@ gawk_popen(const char *cmd, struct redirect *rp)
FILE *current;
os_restore_mode(fileno(stdin));
+#ifdef SIGPIPE
+ signal(SIGPIPE, SIG_DFL);
+#endif /*SIGPIPE*/
current = popen(cmd, binmode("r"));
+#ifdef SIGPIPE
+ signal(SIGPIPE, SIG_IGN);
+#endif /*SIGPIPE*/
if ((BINMODE & BINMODE_INPUT) != 0)
os_setbinmode(fileno(stdin), O_BINARY);
if (current == NULL)