]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/nat/linux-namespaces.c
update copyright year range in GDB files
[thirdparty/binutils-gdb.git] / gdb / nat / linux-namespaces.c
index fd0d4b05ec49daf4ea599e92f4355232dae2cbda..1df8f1bc16a389b194991acf91b7cb92402b9cb8 100644 (file)
@@ -1,6 +1,6 @@
 /* Linux namespaces(7) support.
 
-   Copyright (C) 2015 Free Software Foundation, Inc.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 /* See nat/linux-namespaces.h.  */
 int debug_linux_namespaces;
 
+/* Handle systems without fork.  */
+
+static inline pid_t
+do_fork (void)
+{
+#ifdef HAVE_FORK
+  return fork ();
+#else
+  errno = ENOSYS;
+  return -1;
+#endif
+}
+
 /* Handle systems without setns.  */
 
 static inline int
@@ -644,7 +657,7 @@ linux_mntns_get_helper (void)
       if (gdb_socketpair_cloexec (AF_UNIX, SOCK_STREAM, 0, sv) < 0)
        return NULL;
 
-      h.pid = fork ();
+      h.pid = do_fork ();
       if (h.pid < 0)
        {
          int saved_errno = errno;
@@ -894,7 +907,7 @@ linux_mntns_access_fs (pid_t pid)
   if (fd < 0)
     goto error;
 
-  old_chain = make_cleanup_close (fd);
+  make_cleanup_close (fd);
 
   if (fstat (fd, &sb) != 0)
     goto error;