瀏覽代碼

Use empty signal handler instead SIG_INT for SIGPIPE

Conflicts:
	bin/clish.c
Serj Kalichev 10 年之前
父節點
當前提交
c58580bc3a
共有 1 個文件被更改,包括 13 次插入1 次删除
  1. 13 1
      bin/clish.c

+ 13 - 1
bin/clish.c

@@ -46,6 +46,7 @@ static clish_shell_hooks_t my_hooks = {
     NULL  /* don't register any builtin functions */
 };
 
+static void sighandler(int signo);
 static void help(int status, const char *argv0);
 
 /*--------------------------------------------------------- */
@@ -112,7 +113,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
@@ -375,3 +376,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;
+}