unification of netdev&netdev_dev in pltap&tunnel
[sliver-openvswitch.git] / lib / process.c
index 9f5c35f..9fe742c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
 
 #include <config.h>
 #include "process.h"
-#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
@@ -159,7 +158,7 @@ process_register(const char *name, pid_t pid)
     struct process *p;
     const char *slash;
 
-    assert(sigchld_is_blocked());
+    ovs_assert(sigchld_is_blocked());
 
     p = xzalloc(sizeof *p);
     p->pid = pid;
@@ -308,7 +307,7 @@ process_exited(struct process *p)
 int
 process_status(const struct process *p)
 {
-    assert(p->exited);
+    ovs_assert(p->exited);
     return p->status;
 }
 
@@ -409,14 +408,20 @@ struct stream {
 static int
 stream_open(struct stream *s, size_t max_size)
 {
+    int error;
+
     s->max_size = max_size;
     ds_init(&s->log);
     if (pipe(s->fds)) {
         VLOG_WARN("failed to create pipe: %s", strerror(errno));
         return errno;
     }
-    set_nonblocking(s->fds[0]);
-    return 0;
+    error = set_nonblocking(s->fds[0]);
+    if (error) {
+        close(s->fds[0]);
+        close(s->fds[1]);
+    }
+    return error;
 }
 
 static void
@@ -635,7 +640,7 @@ sigchld_is_blocked(void)
 {
     sigset_t sigs;
 
-    xsigprocmask(SIG_SETMASK, NULL, &sigs);
+    xpthread_sigmask(SIG_SETMASK, NULL, &sigs);
     return sigismember(&sigs, SIGCHLD);
 }
 
@@ -646,11 +651,11 @@ block_sigchld(sigset_t *oldsigs)
 
     sigemptyset(&sigchld);
     sigaddset(&sigchld, SIGCHLD);
-    xsigprocmask(SIG_BLOCK, &sigchld, oldsigs);
+    xpthread_sigmask(SIG_BLOCK, &sigchld, oldsigs);
 }
 
 static void
 unblock_sigchld(const sigset_t *oldsigs)
 {
-    xsigprocmask(SIG_SETMASK, oldsigs, NULL);
+    xpthread_sigmask(SIG_SETMASK, oldsigs, NULL);
 }