Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: precmd: write error: interrupted



On 04/25/2013 10:05 PM, Yuri D'Elia wrote:
I actually tried to set SA_RESTART only when installing the handler for
SIGWINCH when debugging [1]. It works in this case, but I'm not entirely
sure it is side-effect free (is doing an ioctl on the tty safe while
mid-write?).

Attached.

--- signals.c.Orig	2013-04-25 22:34:36.342080454 +0200
+++ signals.c	2013-04-25 22:55:15.994027929 +0200
@@ -112,9 +112,18 @@
     act.sa_handler = (SIGNAL_HANDTYPE) zhandler;
     sigemptyset(&act.sa_mask);        /* only block sig while in handler */
     act.sa_flags = 0;
-# ifdef SA_INTERRUPT                  /* SunOS 4.x */
-    if (interact)
-        act.sa_flags |= SA_INTERRUPT; /* make sure system calls are not restarted */
+# if defined(SIGWINCH) && defined(SA_RESTART)
+    if (sig == SIGWINCH) {
+	act.sa_flags |= SA_RESTART;
+    } else {
+#  ifdef SA_INTERRUPT                  /* SunOS 4.x */
+	act.sa_flags |= SA_INTERRUPT;  /* make sure system calls are not restarted */
+#  endif
+    }
+# else
+#  ifdef SA_INTERRUPT                  /* SunOS 4.x */
+    act.sa_flags |= SA_INTERRUPT;      /* make sure system calls are not restarted */
+#  endif
 # endif
     sigaction(sig, &act, (struct sigaction *)NULL);
 #else
@@ -122,9 +131,13 @@
     struct sigvec vec;
  
     vec.sv_handler = (SIGNAL_HANDTYPE) zhandler;
-    vec.sv_mask = sigmask(sig);    /* mask out this signal while in handler    */
-#  ifdef SV_INTERRUPT
-    vec.sv_flags = SV_INTERRUPT;   /* make sure system calls are not restarted */
+    vec.sv_mask = sigmask(sig);      /* mask out this signal while in handler    */
+#  if defined(SIGWINCH) && defined(SV_INTERRUPT)
+    if (sig != SIGWINCH) {
+	vec.sv_flags = SV_INTERRUPT; /* make sure system calls are not restarted */
+    }
+#  elif defined(SV_INTERRUPT)
+    vec.sv_flags = SV_INTERRUPT;     /* make sure system calls are not restarted */
 #  endif
     sigvec(sig, &vec, (struct sigvec *)NULL);
 # else


Messages sorted by: Reverse Date, Date, Thread, Author