Browse Source

Use empty signal handler instead SIG_INT for SIGPIPE

Serj Kalichev 10 years ago
parent
commit
463398b495
1 changed files with 13 additions and 1 deletions
  1. 13 1
      bin/clish.c

+ 13 - 1
bin/clish.c

@@ -33,6 +33,7 @@
 /* #define version(v) printf("%s\n", QUOTE(v)) */
 #define version(v) printf("%s\n", v)
 
+static void sighandler(int signo);
 static void help(int status, const char *argv0);
 
 /*--------------------------------------------------------- */
@@ -103,7 +104,7 @@ int main(int argc, char **argv)
 	sigaddset(&sigpipe_set, SIGPIPE);
 	sigpipe_act.sa_flags = 0;
 	sigpipe_act.sa_mask = sigpipe_set;
-	sigpipe_act.sa_handler = SIG_IGN;
+	sigpipe_act.sa_handler = &sighandler;
 	sigaction(SIGPIPE, &sigpipe_act, NULL);
 
 #if HAVE_LOCALE_H
@@ -382,3 +383,14 @@ static void help(int status, const char *argv0)
 		printf("\t-z <num>, --histsize=<num>\tCommand history size in lines.\n");
 	}
 }
+
+/*--------------------------------------------------------- */
+/*
+ * Signal handler for SIGPIPE.
+ * It's empty but it's needed to don't ignore SIGPIPE because
+ * SIG_IGN will be inherited while ACTION execution.
+ */
+static void sighandler(int signo)
+{
+	return;
+}