Trait interprocess::os::unix::local_socket::ListenerOptionsExt
source · pub trait ListenerOptionsExt: Sized + Sealed {
// Required method
fn mode(self, mode: mode_t) -> Self;
}
Expand description
Unix-specific listener options.
Required Methods§
sourcefn mode(self, mode: mode_t) -> Self
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.