diff options
| author | bors <bors@rust-lang.org> | 2017-02-05 19:33:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-02-05 19:33:55 +0000 |
| commit | 031c1168b9b3f38405090f6be678a156b7d71e12 (patch) | |
| tree | 38656a85859d0f1a9864ab07b3865b34b3bd4162 /src/libstd/sys | |
| parent | fc02736d59252fe408dd6c2f7e2c4b6f229e4443 (diff) | |
| parent | a419dd1c013846754c0a3c8dae3842c2739864d4 (diff) | |
| download | rust-031c1168b9b3f38405090f6be678a156b7d71e12.tar.gz rust-031c1168b9b3f38405090f6be678a156b7d71e12.zip | |
Auto merge of #39567 - frewsxcv:rollup, r=frewsxcv
Rollup of 12 pull requests - Successful merges: #39439, #39472, #39481, #39491, #39501, #39509, #39514, #39519, #39526, #39528, #39530, #39538 - Failed merges:
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/fd.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs index dcab30aad83..c690fd467ee 100644 --- a/src/libstd/sys/unix/fd.rs +++ b/src/libstd/sys/unix/fd.rs @@ -144,11 +144,24 @@ impl FileDesc { pub fn set_cloexec(&self) -> io::Result<()> { unsafe { let previous = cvt(libc::fcntl(self.fd, libc::F_GETFD))?; - cvt(libc::fcntl(self.fd, libc::F_SETFD, previous | libc::FD_CLOEXEC))?; + let new = previous | libc::FD_CLOEXEC; + if new != previous { + cvt(libc::fcntl(self.fd, libc::F_SETFD, new))?; + } + Ok(()) + } + } + + #[cfg(target_os = "linux")] + pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { + unsafe { + let v = nonblocking as c_int; + cvt(libc::ioctl(self.fd, libc::FIONBIO, &v))?; Ok(()) } } + #[cfg(not(target_os = "linux"))] pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { unsafe { let previous = cvt(libc::fcntl(self.fd, libc::F_GETFL))?; @@ -157,7 +170,9 @@ impl FileDesc { } else { previous & !libc::O_NONBLOCK }; - cvt(libc::fcntl(self.fd, libc::F_SETFL, new))?; + if new != previous { + cvt(libc::fcntl(self.fd, libc::F_SETFL, new))?; + } Ok(()) } } |
