]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/sys/unix/fd.rs
Rollup merge of #50638 - tbu-:pr_open_cloexec_once, r=nagisa
[rust.git] / src / libstd / sys / unix / fd.rs
index 67546d06b4e55055d98b767d0cd1b6a4fec43b5a..4830e38d6a92fd8c4c2b337e54b97c1af0a848cc 100644 (file)
@@ -154,6 +154,13 @@ unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: usize, offset: i64)
         }
     }
 
+    #[cfg(target_os = "linux")]
+    pub fn get_cloexec(&self) -> io::Result<bool> {
+        unsafe {
+            Ok((cvt(libc::fcntl(self.fd, libc::F_GETFD))? & libc::FD_CLOEXEC) != 0)
+        }
+    }
+
     #[cfg(not(any(target_env = "newlib",
                   target_os = "solaris",
                   target_os = "emscripten",