about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-08-25 07:23:18 +0000
committerbors <bors@rust-lang.org>2015-08-25 07:23:18 +0000
commite195aa84b482e01b6eadf14211e4d880063a6794 (patch)
tree863286be09aa0563fa6202fc4eb84818c6762dd4 /src/libstd/sys
parent656c3acdebb6334b82e3e11251dca6d43406e269 (diff)
parent6de7f609ddc6027b4148b7a458f9f766b44cd09f (diff)
downloadrust-e195aa84b482e01b6eadf14211e4d880063a6794.tar.gz
rust-e195aa84b482e01b6eadf14211e4d880063a6794.zip
Auto merge of #27971 - tbu-:pr_cloexec, r=alexcrichton
On Linux the flag is just ignored if it is not supported:
https://lwn.net/Articles/588444/

Still needs the values of O_CLOEXEC on the BSDs.

Touches #24237.
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/fs.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index 751b8e48263..cbbdd223dc2 100644
--- a/src/libstd/sys/unix/fs.rs
+++ b/src/libstd/sys/unix/fs.rs
@@ -212,7 +212,7 @@ impl DirEntry {
 impl OpenOptions {
     pub fn new() -> OpenOptions {
         OpenOptions {
-            flags: 0,
+            flags: libc::O_CLOEXEC,
             read: false,
             write: false,
             mode: 0o666,
@@ -269,6 +269,9 @@ impl File {
             libc::open(path.as_ptr(), flags, opts.mode)
         }));
         let fd = FileDesc::new(fd);
+        // Even though we open with the O_CLOEXEC flag, still set CLOEXEC here,
+        // in case the open flag is not supported (it's just ignored by the OS
+        // in that case).
         fd.set_cloexec();
         Ok(File(fd))
     }