diff --git a/Cargo.lock b/Cargo.lock index fca4f5b..9a88c01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -861,7 +861,7 @@ dependencies = [ [[package]] name = "realm_syscall" -version = "0.1.0" +version = "0.1.1" dependencies = [ "daemonize", "libc", diff --git a/realm_syscall/Cargo.toml b/realm_syscall/Cargo.toml index e2be839..c68f5e0 100644 --- a/realm_syscall/Cargo.toml +++ b/realm_syscall/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "realm_syscall" -version = "0.1.0" +version = "0.1.1" authors = ["zephyr "] description = "Realm's convenient syscall collections" repository = "https://github.com/zhboner/realm/realm_syscall" diff --git a/realm_syscall/src/daemon.rs b/realm_syscall/src/daemon.rs index 5eef552..074e002 100644 --- a/realm_syscall/src/daemon.rs +++ b/realm_syscall/src/daemon.rs @@ -1,6 +1,8 @@ use std::env::current_dir; use daemonize::Daemonize; +/// Daemonize. +/// /// Fork the process in the background, /// disassociate from process group and the control terminal. /// diff --git a/realm_syscall/src/nofile.rs b/realm_syscall/src/nofile.rs index d5866f2..5699bbd 100644 --- a/realm_syscall/src/nofile.rs +++ b/realm_syscall/src/nofile.rs @@ -2,6 +2,7 @@ use std::io::{Error, Result}; use libc::{rlimit, rlim_t, RLIMIT_NOFILE}; /// Set nofile limitation. +/// /// `CAP_NET_ADMIN` privilege is required if exceeds hard limitation. /// /// Reference: diff --git a/realm_syscall/src/socket.rs b/realm_syscall/src/socket.rs index 58c68f8..fce540f 100644 --- a/realm_syscall/src/socket.rs +++ b/realm_syscall/src/socket.rs @@ -1,7 +1,14 @@ use std::io::Result; use socket2::{Socket, Domain, Type}; -/// Create a new socket. +/// Create a new non-blocking socket. +/// +/// On unix-like platforms, [`SOCK_NONBLOCK`](libc::SOCK_NONBLOCK) and +/// [`SOCK_CLOEXEC`](libc::SOCK_CLOEXEC) are assigned +/// when creating a new socket, which saves a [`fcntl`](libc::fcntl) syscall. +/// +/// On other platforms, a socket is created without extra flags +/// then set to `non_blocking`. #[cfg(any( target_os = "android", target_os = "dragonfly",