diff options
| author | Mathieu Poumeyrol <kali@zoy.org> | 2016-09-27 10:16:49 -0400 |
|---|---|---|
| committer | Mathieu Poumeyrol <mathieu.poumeyrol@snips.ai> | 2016-09-28 19:43:11 +0200 |
| commit | ed5e5428192f6f72afcb4becc3d78a18133613df (patch) | |
| tree | 9d800b1ae90dcff672a7acbaf228213616d91a2a /src/libstd/sys/unix | |
| parent | 6f6e261e20fd1a770cb3477205c192dd158897f8 (diff) | |
| download | rust-ed5e5428192f6f72afcb4becc3d78a18133613df.tar.gz rust-ed5e5428192f6f72afcb4becc3d78a18133613df.zip | |
MSG_NOSIGNAL on linux
Diffstat (limited to 'src/libstd/sys/unix')
| -rw-r--r-- | src/libstd/sys/unix/ext/net.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 3f93fce1935..f2e40714b46 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -28,6 +28,11 @@ use sys::cvt; use sys::net::Socket; use sys_common::{AsInner, FromInner, IntoInner}; +#[cfg(target_os = "linux")] +const MSG_NOSIGNAL: libc::c_int = 0x4000; +#[cfg(not(target_os = "linux"))] +const MSG_NOSIGNAL: libc::c_int = 0x0; // unused dummy value + fn sun_path_offset() -> usize { unsafe { // Work with an actual instance of the type since using a null pointer is UB @@ -686,11 +691,12 @@ impl UnixDatagram { fn inner(d: &UnixDatagram, buf: &[u8], path: &Path) -> io::Result<usize> { unsafe { let (addr, len) = sockaddr_un(path)?; + let flags = if cfg!(target_os = "linux") { MSG_NOSIGNAL } else { 0 }; let count = cvt(libc::sendto(*d.0.as_inner(), buf.as_ptr() as *const _, buf.len(), - 0, + flags, &addr as *const _ as *const _, len))?; Ok(count as usize) |
