From: Ed Maste Date: Fri, 28 Sep 2012 21:06:41 +0000 (+0000) Subject: lib: Add xpipe_nonblocking helper X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0d95206c068d95460a068defd76274e73225a4a;p=openvswitch lib: Add xpipe_nonblocking helper Signed-off-by: Ed Maste Signed-off-by: Ben Pfaff --- diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c index 21ebb5a8..7cfbd053 100644 --- a/lib/fatal-signal.c +++ b/lib/fatal-signal.c @@ -74,9 +74,7 @@ fatal_signal_init(void) inited = true; - xpipe(signal_fds); - xset_nonblocking(signal_fds[0]); - xset_nonblocking(signal_fds[1]); + xpipe_nonblocking(signal_fds); sigemptyset(&fatal_signal_set); for (i = 0; i < ARRAY_SIZE(fatal_signals); i++) { diff --git a/lib/process.c b/lib/process.c index 91dfc064..9f5c35f2 100644 --- a/lib/process.c +++ b/lib/process.c @@ -82,9 +82,7 @@ process_init(void) inited = true; /* Create notification pipe. */ - xpipe(fds); - xset_nonblocking(fds[0]); - xset_nonblocking(fds[1]); + xpipe_nonblocking(fds); /* Set up child termination signal handler. */ memset(&sa, 0, sizeof sa); diff --git a/lib/signals.c b/lib/signals.c index b712f7e7..152afcf6 100644 --- a/lib/signals.c +++ b/lib/signals.c @@ -63,9 +63,7 @@ signal_init(void) static bool inited; if (!inited) { inited = true; - xpipe(fds); - xset_nonblocking(fds[0]); - xset_nonblocking(fds[1]); + xpipe_nonblocking(fds); } } diff --git a/lib/socket-util.c b/lib/socket-util.c index e32c03dd..f8b44cc1 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -893,6 +893,14 @@ xpipe(int fds[2]) } } +void +xpipe_nonblocking(int fds[2]) +{ + xpipe(fds); + xset_nonblocking(fds[0]); + xset_nonblocking(fds[1]); +} + void xsocketpair(int domain, int type, int protocol, int fds[2]) { diff --git a/lib/socket-util.h b/lib/socket-util.h index bacb236f..a00b32e5 100644 --- a/lib/socket-util.h +++ b/lib/socket-util.h @@ -64,6 +64,7 @@ int fsync_parent_dir(const char *file_name); int get_mtime(const char *file_name, struct timespec *mtime); void xpipe(int fds[2]); +void xpipe_nonblocking(int fds[2]); char *describe_fd(int fd);