Trait interprocess::os::unix::local_socket::ListenerOptionsExt

source ·
pub trait ListenerOptionsExt: Sized + Sealed {
    // Required method
    fn mode(self, mode: mode_t) -> Self;
}
Available on Unix only.
Expand description

Unix-specific listener options.

Required Methods§

source

fn mode(self, mode: mode_t) -> Self

Sets the file mode (Unix permissions) to be applied to the socket file.

§Implementation notes

An opportunistic fchmod() is performed on the socket. If the system responds with a EINVAL, Interprocess concludes that fchmod() on sockets is not supported on the platform, remembers this fact in an atomic global variable and falls back to a temporary umask change.

Linux is known to support fchmod() on Unix domain sockets, while FreeBSD is known not to.

Note that the fallback behavior inherently racy: if you specify this mode as, say, 666₈ and have another thread create a file during the critical section between the first umask() call and the one performed just before returning from .create_*(), that file will have mode 666₈. There is nothing Interprocess can do about this, as POSIX prescribes the umask to be shared across threads.

Object Safety§

This trait is not object safe.

Implementors§