recognize external links passed via command line
[sliver-openvswitch.git] / lib / process.c
index 9f5c35f..795a136 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