Fix signal handling some more.
[sw-tools] / src / sw_rsh.c
index 4f2be0d..91aa82b 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: sw_rsh.c,v 1.3 1999/06/18 18:58:54 mdw Exp $
+ * $Id: sw_rsh.c,v 1.5 1999/06/24 16:02:22 mdw Exp $
  *
  * Run remote commands
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: sw_rsh.c,v $
+ * Revision 1.5  1999/06/24 16:02:22  mdw
+ * Fix signal handling some more.
+ *
+ * Revision 1.4  1999/06/24 15:51:17  mdw
+ * Fix signal handlers so they don't corrupt `errno'.
+ *
  * Revision 1.3  1999/06/18 18:58:54  mdw
  * Signal handling fixes.
  *
@@ -632,6 +638,7 @@ done:
 
 static void sigchld(int sig)
 {
+  int e = errno;
 #ifdef DEBUG_SIGCHLD
   int status;
   while (waitpid(-1, &status, WNOHANG) > 0) {
@@ -648,6 +655,7 @@ static void sigchld(int sig)
   while (waitpid(-1, 0, WNOHANG) > 0)
     ;
 #endif
+  errno = e;
 }
 
 /* --- @swrsh@ --- *
@@ -711,10 +719,11 @@ int swrsh(sw_remote *r, const char *host, const char *cmd, char *argv[])
 
     /* --- Child end of a local job --- */
 
+    signal(SIGINT, SIG_DFL);
+    signal(SIGQUIT, SIG_DFL);
+
     if (!host) {
       r->fdin = r->fdout = sk[1];
-      signal(SIGINT, SIG_DFL);
-      signal(SIGQUIT, SIG_DFL);
       remote(r, cmd, argv, environ);
     }