Index: trunk/src/samhain.c
===================================================================
--- trunk/src/samhain.c	(revision 378)
+++ trunk/src/samhain.c	(revision 379)
@@ -1376,4 +1376,5 @@
   /* --------  INIT  --------    
    */
+  sh_unix_ign_sigpipe();
 
   /* Restrict error logging to stderr.
Index: trunk/src/sh_err_console.c
===================================================================
--- trunk/src/sh_err_console.c	(revision 378)
+++ trunk/src/sh_err_console.c	(revision 379)
@@ -290,5 +290,4 @@
   /* static int logkey_seen = 0; */
   int    error;
-  struct sigaction sa_new, sa_old;
   static int blockMe = 0;
   int    val_return;
@@ -311,12 +310,4 @@
 #endif
 
-  sa_new.sa_handler = SIG_IGN;
-  (void) sigemptyset(&sa_new.sa_mask);
-  sa_new.sa_flags   = 0;
-
-  /* Ignore SIGPIPE in case the console is actually a pipe.
-   */
-  (void) retry_sigaction(FIL__, __LINE__, SIGPIPE, &sa_new, &sa_old);
- 
   if (sh.flag.isdaemon == S_FALSE || OnlyStderr == S_TRUE)
     {
@@ -331,5 +322,4 @@
        * fprintf (stderr, "%s\n", errmsg); 
        */
-      (void) retry_sigaction(FIL__, __LINE__, SIGPIPE, &sa_old, NULL);
       blockMe = 0;
       SL_RETURN(0, _("sh_log_console"));
@@ -392,5 +382,4 @@
     retval = 0;
 
-  (void) retry_sigaction(FIL__, __LINE__, SIGPIPE, &sa_old, NULL);
   blockMe = 0;
   SL_RETURN(retval, _("sh_log_console"));
Index: trunk/src/sh_forward.c
===================================================================
--- trunk/src/sh_forward.c	(revision 378)
+++ trunk/src/sh_forward.c	(revision 379)
@@ -5055,7 +5055,4 @@
   unsigned long tchkold;
 
-  struct  sigaction  new_act;
-  struct  sigaction  old_act;
-
   int setsize_fd;
 
@@ -5067,12 +5064,4 @@
   
   SL_ENTER(_("sh_receive"));
-
-  /* ignore SIGPIPE (instead get EPIPE if connection is closed)
-   *      --- we have called sh_unix_init() already ---
-   */
-  new_act.sa_handler = SIG_IGN;
-  sigemptyset( &new_act.sa_mask );         /* set an empty mask       */
-  new_act.sa_flags = 0;                    /* init sa_flags           */
-  retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act);
 
   if ( sh_forward_printerr_final(0) < 0)
Index: trunk/src/sh_log_check.c
===================================================================
--- trunk/src/sh_log_check.c	(revision 378)
+++ trunk/src/sh_log_check.c	(revision 379)
@@ -876,7 +876,4 @@
   struct task_entry * entry;
 
-  struct  sigaction   new_act;
-  struct  sigaction   old_act;
-
   volatile int        status;
   char * tmp;
@@ -886,17 +883,7 @@
   if (logfile->fp)
     {
-      /* ignore SIGPIPE (instead get EPIPE if connection is closed)
-       */
-      memset(&new_act, 0, sizeof(struct  sigaction));
-      new_act.sa_handler = SIG_IGN;
-      (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act);
-
       /* Result cannot be larger than 8192, thus cast is ok
        */
       status = (int) sh_string_read(s, logfile->fp, 8192);
-
-      /* restore old signal handler
-       */
-      (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &old_act, NULL);
 
       if (status <= 0)
Index: trunk/src/sh_mail.c
===================================================================
--- trunk/src/sh_mail.c	(revision 378)
+++ trunk/src/sh_mail.c	(revision 379)
@@ -531,7 +531,4 @@
     static int   failcount = 0;
     FILE       * connfile  = NULL;
-
-    struct  sigaction  old_act;
-    struct  sigaction  new_act;
 
     static  time_t fail_time = 0;
@@ -671,12 +668,4 @@
 
     /* ---------- Connect ---------------------------------------- */
-
-    /* -- Catch (ignore) 'broken pipe'.
-     */
-    new_act.sa_handler = SIG_IGN;
-    sigemptyset( &new_act.sa_mask );         /* set an empty mask       */
-    new_act.sa_flags = 0;                    /* init sa_flags           */
-
-    (void) sigaction (SIGPIPE, &new_act, &old_act);
 
     errcount = 0;
@@ -825,8 +814,4 @@
       }
 
-    /* --- Reset signal. ---
-     */
-    (void) sigaction (SIGPIPE, &old_act, NULL);
-
     if (errcount == address_num)
       {
Index: trunk/src/sh_prelink.c
===================================================================
--- trunk/src/sh_prelink.c	(revision 378)
+++ trunk/src/sh_prelink.c	(revision 379)
@@ -164,6 +164,4 @@
   int    status = 0;
   char * p;
-  struct  sigaction  new_act;
-  struct  sigaction  old_act;
 
   SL_ENTER(_("sh_prelink_run"));
@@ -256,9 +254,4 @@
       SL_RETURN ((-1), _("sh_prelink_run"));
     }
-
-  /* ignore SIGPIPE (instead get EPIPE if connection is closed)
-   */
-  new_act.sa_handler = SIG_IGN;
-  (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act);
 
   /* read from pipe
@@ -275,8 +268,4 @@
   }
 
-  /* restore old signal handler
-   */
-  (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &old_act, NULL);
-
   /* close pipe and return exit status
    */
Index: trunk/src/sh_processcheck.c
===================================================================
--- trunk/src/sh_processcheck.c	(revision 378)
+++ trunk/src/sh_processcheck.c	(revision 379)
@@ -1022,6 +1022,4 @@
   int    status = 0;
   char * p;
-  struct  sigaction  new_act;
-  struct  sigaction  old_act;
   int retval = 0;
   char  dir[SH_PATHBUF];
@@ -1076,9 +1074,4 @@
     }
 
-  /* ignore SIGPIPE (instead get EPIPE if connection is closed)
-   */
-  new_act.sa_handler = SIG_IGN;
-  (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act);
-
   /* read from the open pipe
    */
@@ -1087,8 +1080,4 @@
       retval = sh_processes_readps (task.pipe, res, str, len, flag, pid);
     }
-
-  /* restore old signal handler
-   */
-  (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &old_act, NULL);
 
   /* close pipe and return exit status
Index: trunk/src/sh_tools.c
===================================================================
--- trunk/src/sh_tools.c	(revision 378)
+++ trunk/src/sh_tools.c	(revision 379)
@@ -1046,17 +1046,8 @@
   int    num_sel;
   
-  struct  sigaction  new_act;
-  struct  sigaction  old_act;
   char    errbuf[SH_ERRBUF_SIZE];
 
   SL_ENTER(_("sh_write_select"));
 
-  /* ignore SIGPIPE (instead get EPIPE if connection is closed)
-   */
-  new_act.sa_handler = SIG_IGN;
-  sigemptyset( &new_act.sa_mask );         /* set an empty mask       */
-  new_act.sa_flags = 0;                    /* init sa_flags           */
-  sigaction (SIGPIPE, &new_act, &old_act);
-  
   FD_ZERO(&fds);
   FD_SET(sockfd, &fds);
@@ -1086,5 +1077,5 @@
 	      continue;
 	    *w_error = errno;
-	    sigaction (SIGPIPE, &old_act, NULL);
+
 	    sh_error_message(*w_error, errbuf, sizeof(errbuf));
 	    sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, errno, MSG_E_SUBGEN,
@@ -1107,5 +1098,5 @@
 	      continue;
 	    *w_error = errno;
-	    sigaction (SIGPIPE, &old_act, NULL);
+
 	    sh_error_message(*w_error, errbuf, sizeof(errbuf));
 	    sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, errno, MSG_E_SUBGEN,
@@ -1136,5 +1127,5 @@
 	    *w_error = 0;
 #endif
-	    sigaction (SIGPIPE, &old_act, NULL);
+
 	    TPT(( 0, FIL__, __LINE__, _("msg=<Timeout>\n")));
 	    SL_RETURN( countbytes, _("sh_write_select"));
@@ -1162,5 +1153,5 @@
 	  {
 	    *w_error = errno;
-	    sigaction (SIGPIPE, &old_act, NULL);
+
 	    sh_error_message(*w_error, errbuf, sizeof(errbuf));
 	    sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, errno, MSG_E_SUBGEN,
@@ -1174,5 +1165,5 @@
 	  {
 	    *w_error = errno;
-	    sigaction (SIGPIPE, &old_act, NULL);
+
 	    TPT(( 0, FIL__, __LINE__, _("msg=<count == 0>\n")));
 	    SL_RETURN( countbytes, _("sh_write_select"));
@@ -1180,9 +1171,4 @@
       }
   }
-
-
-  /* restore signal handler
-   */
-  sigaction (SIGPIPE, &old_act, NULL);
 
   *w_error = 0;
Index: trunk/src/sh_unix.c
===================================================================
--- trunk/src/sh_unix.c	(revision 378)
+++ trunk/src/sh_unix.c	(revision 379)
@@ -699,4 +699,18 @@
 }
 
+void sh_unix_ign_sigpipe()
+{
+  struct sigaction ignact;
+
+  ignact.sa_handler = SIG_IGN;            /* signal action           */
+  sigemptyset( &ignact.sa_mask );         /* set an empty mask       */
+  ignact.sa_flags = 0;                    /* init sa_flags           */
+
+#ifdef SIGPIPE
+  retry_sigaction(FIL__, __LINE__, SIGPIPE,   &ignact, NULL);
+#endif
+
+  return;
+}
 static
 void sh_unix_siginstall (int goDaemon)
@@ -831,9 +845,5 @@
 #endif
 #ifdef SIGPIPE
-#ifdef HAVE_PTHREAD
   retry_sigaction(FIL__, __LINE__, SIGPIPE,   &ignact, &oldact);
-#else
-  retry_sigaction(FIL__, __LINE__, SIGPIPE,      &act, &oldact);
-#endif
 #endif
 #ifdef SIGALRM
