fatal-signal: SIGPIPE for Windows.
authorGurucharan Shetty <gshetty@nicira.com>
Wed, 26 Feb 2014 18:44:46 +0000 (10:44 -0800)
committerGurucharan Shetty <gshetty@nicira.com>
Wed, 26 Feb 2014 20:40:30 +0000 (12:40 -0800)
Windows does not have a SIGPIPE. We ignore SIGPIPE for
Linux. To compile on Windows, carve out a new function
to ignore SIGPIPE on Linux.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
12 files changed:
lib/fatal-signal.c
lib/fatal-signal.h
ovsdb/ovsdb-client.c
ovsdb/ovsdb-server.c
ovsdb/ovsdb-tool.c
tests/test-controller.c
tests/test-vconn.c
utilities/ovs-dpctl.c
utilities/ovs-ofctl.c
utilities/ovs-vsctl.c
vswitchd/ovs-vswitchd.c
vtep/vtep-ctl.c

index 6b3dd20..df67a09 100644 (file)
@@ -218,6 +218,14 @@ fatal_signal_wait(void)
     poll_fd_wait_event(signal_fds[0], wevent, POLLIN);
 }
 
+void
+fatal_ignore_sigpipe(void)
+{
+#ifndef _WIN32
+    signal(SIGPIPE, SIG_IGN);
+#endif
+}
+
 static void
 atexit_handler(void)
 {
index b458d3d..caf24ec 100644 (file)
@@ -27,6 +27,7 @@ void fatal_signal_add_hook(void (*hook_cb)(void *aux),
 void fatal_signal_fork(void);
 void fatal_signal_run(void);
 void fatal_signal_wait(void);
+void fatal_ignore_sigpipe(void);
 
 /* Convenience functions for unlinking files upon termination.
  *
index f149eec..d60d7ca 100644 (file)
@@ -31,6 +31,7 @@
 #include "daemon.h"
 #include "dirs.h"
 #include "dynamic-string.h"
+#include "fatal-signal.h"
 #include "json.h"
 #include "jsonrpc.h"
 #include "lib/table.h"
@@ -88,7 +89,7 @@ main(int argc, char *argv[])
     proctitle_init(argc, argv);
     set_program_name(argv[0]);
     parse_options(argc, argv);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
 
     if (optind >= argc) {
         ovs_fatal(0, "missing command name; use --help for help");
index bdcdad9..6de77e4 100644 (file)
@@ -27,6 +27,7 @@
 #include "dirs.h"
 #include "dummy.h"
 #include "dynamic-string.h"
+#include "fatal-signal.h"
 #include "file.h"
 #include "hash.h"
 #include "json.h"
@@ -137,7 +138,7 @@ main(int argc, char *argv[])
     proctitle_init(argc, argv);
     set_program_name(argv[0]);
     service_start(&argc, &argv);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
     process_init();
 
     parse_options(&argc, &argv, &remotes, &unixctl_path, &run_command);
index 5e2b71b..2ae782e 100644 (file)
@@ -27,6 +27,7 @@
 #include "compiler.h"
 #include "dirs.h"
 #include "dynamic-string.h"
+#include "fatal-signal.h"
 #include "file.h"
 #include "lockfile.h"
 #include "log.h"
@@ -56,7 +57,7 @@ main(int argc, char *argv[])
 {
     set_program_name(argv[0]);
     parse_options(argc, argv);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
     run_command(argc - optind, argv + optind, get_all_commands());
     return 0;
 }
index f487d8c..a615ab4 100644 (file)
@@ -27,6 +27,7 @@
 #include "command-line.h"
 #include "compiler.h"
 #include "daemon.h"
+#include "fatal-signal.h"
 #include "learning-switch.h"
 #include "ofp-parse.h"
 #include "ofp-version-opt.h"
@@ -105,7 +106,7 @@ main(int argc, char *argv[])
     proctitle_init(argc, argv);
     set_program_name(argv[0]);
     parse_options(argc, argv);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
 
     if (argc - optind < 1) {
         ovs_fatal(0, "at least one vconn argument required; "
index f54a0df..76757f4 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include "command-line.h"
+#include "fatal-signal.h"
 #include "ofp-msgs.h"
 #include "ofp-util.h"
 #include "ofpbuf.h"
@@ -436,7 +437,7 @@ main(int argc, char *argv[])
     set_program_name(argv[0]);
     vlog_set_levels(NULL, VLF_ANY_FACILITY, VLL_EMER);
     vlog_set_levels(NULL, VLF_CONSOLE, VLL_DBG);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
 
     time_alarm(10);
 
index 3b1dff1..66f87fe 100644 (file)
@@ -35,6 +35,7 @@
 #include "dirs.h"
 #include "dpif.h"
 #include "dynamic-string.h"
+#include "fatal-signal.h"
 #include "flow.h"
 #include "match.h"
 #include "netdev.h"
@@ -73,7 +74,7 @@ main(int argc, char *argv[])
 {
     set_program_name(argv[0]);
     parse_options(argc, argv);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
     run_command(argc - optind, argv + optind, get_all_commands());
     return 0;
 }
index 69dd34f..4ab9ca4 100644 (file)
@@ -36,6 +36,7 @@
 #include "compiler.h"
 #include "dirs.h"
 #include "dynamic-string.h"
+#include "fatal-signal.h"
 #include "nx-match.h"
 #include "odp-util.h"
 #include "ofp-actions.h"
@@ -113,7 +114,7 @@ main(int argc, char *argv[])
 {
     set_program_name(argv[0]);
     parse_options(argc, argv);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
     run_command(argc - optind, argv + optind, get_all_commands());
     return 0;
 }
index c563eee..62a66c5 100644 (file)
@@ -31,6 +31,7 @@
 #include "compiler.h"
 #include "dirs.h"
 #include "dynamic-string.h"
+#include "fatal-signal.h"
 #include "hash.h"
 #include "json.h"
 #include "ovsdb-data.h"
@@ -176,7 +177,7 @@ main(int argc, char *argv[])
     char *args;
 
     set_program_name(argv[0]);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
     vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
     vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_WARN);
     ovsrec_init();
index da18a0a..ca76aef 100644 (file)
@@ -32,6 +32,7 @@
 #include "dirs.h"
 #include "dpif.h"
 #include "dummy.h"
+#include "fatal-signal.h"
 #include "memory.h"
 #include "netdev.h"
 #include "openflow/openflow.h"
@@ -72,7 +73,7 @@ main(int argc, char *argv[])
     set_program_name(argv[0]);
     service_start(&argc, &argv);
     remote = parse_options(argc, argv, &unixctl_path);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
     ovsrec_init();
 
     daemonize_start();
index 233367b..fc7998b 100644 (file)
@@ -31,6 +31,7 @@
 #include "compiler.h"
 #include "dirs.h"
 #include "dynamic-string.h"
+#include "fatal-signal.h"
 #include "hash.h"
 #include "json.h"
 #include "ovsdb-data.h"
@@ -167,7 +168,7 @@ main(int argc, char *argv[])
     char *args;
 
     set_program_name(argv[0]);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
     vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
     vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_WARN);
     vteprec_init();