Skip to content

Commit

Permalink
fatal-signal: SIGPIPE for Windows.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
shettyg committed Feb 26, 2014
1 parent 0c10054 commit 8a777cf
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 10 deletions.
8 changes: 8 additions & 0 deletions lib/fatal-signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions lib/fatal-signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
3 changes: 2 additions & 1 deletion ovsdb/ovsdb-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion ovsdb/ovsdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion ovsdb/ovsdb-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/test-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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; "
Expand Down
3 changes: 2 additions & 1 deletion tests/test-vconn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion utilities/ovs-dpctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion utilities/ovs-ofctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion utilities/ovs-vsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion vswitchd/ovs-vswitchd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion vtep/vtep-ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 8a777cf

Please sign in to comment.