[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9076: coreutils-8.12 uses SA_RESETHAND and SA_RESTART unconditionall
From: |
Paul Eggert |
Subject: |
bug#9076: coreutils-8.12 uses SA_RESETHAND and SA_RESTART unconditionally |
Date: |
Fri, 15 Jul 2011 18:11:43 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10 |
Here are three proposed patches to coreutils to address
the SA_RESETHAND and SA_RESTART issues. I hope that
if you combine them with the patch I already installed:
http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=837e1f55196f826b92d660808f594fde36651655
these should fix all the issues mentioned here.
Joachim, could you please try these? Thanks.
>From bbd4c9edfa4bd5650106261b7d9b1dd434d91581 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Fri, 15 Jul 2011 17:38:32 -0700
Subject: [PATCH 1/3] dd: port to NonStop (Bug#9076)
* src/dd.c (SA_RESETHAND): Define to 0 if not defined.
---
src/dd.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/dd.c b/src/dd.c
index 3e75412..0824f6c 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -55,6 +55,11 @@
# endif
#endif
+/* NonStop circa 2011 lacks SA_RESETHAND; see Bug#9076. */
+#ifndef SA_RESETHAND
+# define SA_RESETHAND 0
+#endif
+
#ifndef SIGINFO
# define SIGINFO SIGUSR1
#endif
--
1.7.4.4
>From 995299ff155bef70a3b153dc8cef11ed9b1d8904 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Fri, 15 Jul 2011 17:39:28 -0700
Subject: [PATCH 2/3] ls: port to NonStop (Bug#9076)
* src/ls.c (SA_RESTART): Define to 0 if not defined.
---
src/ls.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/ls.c b/src/ls.c
index c604e14..680a7c3 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -74,6 +74,14 @@
# endif
#endif
+/* NonStop circa 2011 lacks both SA_RESTART and siginterrupt, so don't
+ restart syscalls after a signal handler fires. This may cause
+ colors to get messed up on the screen if 'ls' is interrupted, but
+ that's the best we can do on such a platform. */
+#ifndef SA_RESTART
+# define SA_RESTART 0
+#endif
+
#include "system.h"
#include <fnmatch.h>
--
1.7.4.4
>From 638e670d76b3bf573f6a9930b376811b5663881a Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Fri, 15 Jul 2011 17:48:38 -0700
Subject: [PATCH 3/3] timeout: port to NonStop (Bug#9077)
* src/timeout.c (SA_RESTART): Define to 0 if not defined.
(main): Don't assume signal handling uses SA_RESTART.
---
src/timeout.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/timeout.c b/src/timeout.c
index ef660a7..895d720 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -64,6 +64,11 @@
# include <sys/resource.h>
#endif
+/* NonStop circa 2011 lacks both SA_RESTART and siginterrupt. */
+#ifndef SA_RESTART
+# define SA_RESTART 0
+#endif
+
#define PROGRAM_NAME "timeout"
#define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady")
@@ -256,7 +261,8 @@ install_signal_handlers (int sigterm)
struct sigaction sa;
sigemptyset (&sa.sa_mask); /* Allow concurrent calls to handler */
sa.sa_handler = cleanup;
- sa.sa_flags = SA_RESTART; /* restart syscalls (like wait() below) */
+ sa.sa_flags = SA_RESTART; /* Restart syscalls if possible, as that's
+ more likely to work cleanly. */
sigaction (SIGALRM, &sa, NULL); /* our timeout. */
sigaction (SIGINT, &sa, NULL); /* Ctrl-C at terminal for example. */
@@ -354,18 +360,15 @@ main (int argc, char **argv)
}
else
{
+ pid_t wait_result;
int status;
alarm (timeout);
- /* We're just waiting for a single process here, so wait() suffices.
- Note the signal() calls above on GNU/Linux and BSD at least,
- essentially call the lower level sigaction() with the SA_RESTART flag
- set, which ensures the following wait call will only return if the
- child exits, not on this process receiving a signal. Also we're not
- passing WUNTRACED | WCONTINUED to a waitpid() call and so will not get
- indication that the child has stopped or continued. */
- if (wait (&status) == -1)
+ while ((wait_result = wait (&status)) < 0 && errno == EINTR)
+ continue;
+
+ if (wait_result < 0)
{
/* shouldn't happen. */
error (0, errno, _("error waiting for command"));
--
1.7.4.4
bug#9076: coreutils-8.12 uses SA_RESETHAND and SA_RESTART unconditionally, Bruno Haible, 2011/07/15