Fix stale cleanup left by linux_mntns_access_fs
[deliverable/binutils-gdb.git] / gdb / nat / linux-namespaces.c
index f18e40dc89e69f8d531b2906a47fe6d00093f7e0..434142936e2f236066d61cb60f2837e59be84e41 100644 (file)
@@ -34,17 +34,23 @@ int debug_linux_namespaces;
 
 /* Handle systems without setns.  */
 
-#ifndef HAVE_SETNS
-static int
-setns (int fd, int nstype)
+static inline int
+do_setns (int fd, int nstype)
 {
-#ifdef __NR_setns
+#ifdef HAVE_SETNS
+  return setns (fd, nstype);
+#elif defined __NR_setns
   return syscall (__NR_setns, fd, nstype);
 #else
   errno = ENOSYS;
   return -1;
 #endif
 }
+
+/* Handle systems without MSG_CMSG_CLOEXEC.  */
+
+#ifndef MSG_CMSG_CLOEXEC
+#define MSG_CMSG_CLOEXEC 0
 #endif
 
 /* A Linux namespace.  */
@@ -489,7 +495,7 @@ mnsh_recv_message (int sock, enum mnsh_msg_type *type,
 static ssize_t
 mnsh_handle_setns (int sock, int fd, int nstype)
 {
-  int result = setns (fd, nstype);
+  int result = do_setns (fd, nstype);
 
   return mnsh_return_int (sock, result, errno);
 }
@@ -888,7 +894,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;
This page took 0.041173 seconds and 4 git commands to generate.