Up

Module type S

Signature

Interface to Linux-specific system calls

sysinfo

module Sysinfo : sig .. end

Filesystem functions

val sendfile : (?pos:int -> ?len:int -> fd:Core_unix.File_descr.t -> Core_unix.File_descr.t -> int) Core_kernel.Std.Or_error.t

sendfile ?pos ?len ~fd sock sends mmap-able data from file descriptor fd to socket sock using offset pos and length len.

Returns the number of characters actually written.
NOTE: if the returned value is unequal to what was requested (= the initial size of the data by default), the system call may have been interrupted by a signal, the source file may have been truncated during operation, or a timeout occurred on the socket during sending. It is currently impossible to find out which of the events above happened. Calling sendfile several times on the same descriptor that only partially accepted data due to a timeout will eventually lead to the unix error EAGAIN.
Raises [Unix_error] on Unix-errors.
Param [default] pos = 0
Param [default] len = length of data (file) associated with descriptor fd

Non-portable TCP-functionality

type tcp_bool_option =
| TCP_CORK
val __bin_read_tcp_bool_option__ : (int -> tcp_bool_option) Core_kernel.Std.Bin_prot.Read.reader
val tcp_bool_option_of_sexp : Sexplib.Sexp.t -> tcp_bool_option
val sexp_of_tcp_bool_option : tcp_bool_option -> Sexplib.Sexp.t

gettcpopt_bool sock opt

Returns the current value of the boolean TCP socket option opt for socket sock.
val settcpopt_bool : (Core_unix.File_descr.t -> tcp_bool_option -> bool -> unit) Core_kernel.Std.Or_error.t

settcpopt_bool sock opt v sets the current value of the boolean TCP socket option opt for socket sock to value v.

val send_nonblocking_no_sigpipe : (Core_unix.File_descr.t -> ?pos:int -> ?len:int -> string -> int option) Core_kernel.Std.Or_error.t

send_nonblocking_no_sigpipe sock ?pos ?len buf tries to do a nonblocking send on socket sock given buffer buf, offset pos and length len. Prevents SIGPIPE, i.e. raise a Unix-error in that case immediately.

Returns Some bytes_written or None if the operation would have blocked.
Param [pos] default = 0
Param [len] default = String.length buf - pos
Raises [Invalid_argument] if the designated buffer range is invalid.
Raises [Unix_error] on Unix-errors.
val send_no_sigpipe : (Core_unix.File_descr.t -> ?pos:int -> ?len:int -> string -> int) Core_kernel.Std.Or_error.t

send_no_sigpipe sock ?pos ?len buf tries to do a blocking send on socket sock given buffer buf, offset pos and length len. Prevents SIGPIPE, i.e. raise a Unix-error in that case immediately.

Returns the number of bytes written.
Param [pos] default = 0
Param [len] default = String.length buf - pos
Raises [Invalid_argument] if the designated buffer range is invalid.
Raises [Unix_error] on Unix-errors.
val sendmsg_nonblocking_no_sigpipe : (Core_unix.File_descr.t -> ?count:int -> string Core_unix.IOVec.t array -> int option) Core_kernel.Std.Or_error.t

sendmsg_nonblocking_no_sigpipe sock ?count iovecs tries to do a nonblocking send on socket sock using count I/O-vectors iovecs. Prevents SIGPIPE, i.e. raises a Unix-error in that case immediately.

Returns Some bytes_written or None if the operation would have blocked.
Raises [Invalid_argument] if the designated ranges are invalid.
Raises [Unix_error] on Unix-errors.

Clock functions

module Clock : sig .. end

Timerfd functions

module Timerfd : sig .. end

Parent death notifications

val pr_set_pdeathsig : (Signal.t -> unit) Core_kernel.Std.Or_error.t

pr_set_pdeathsig s sets the signal s to be sent to the executing process when its parent dies. NOTE: the parent may have died before or while executing this system call. To make sure that you do not miss this event, you should call getppid to get the parent process id after this system call. If the parent has died, the returned parent PID will be 1, i.e. the init process will have adopted the child. You should then either send the signal to yourself using Unix.kill, or execute an appropriate handler.

val pr_get_pdeathsig : (unit -> Signal.t) Core_kernel.Std.Or_error.t

pr_get_pdeathsig () get the signal that will be sent to the currently executing process when its parent dies.

Task name

val pr_set_name_first16 : (string -> unit) Core_kernel.Std.Or_error.t

pr_set_name_first16 name sets the name of the executing thread to name. Only the first 16 bytes in name will be used, the rest is ignored.

val pr_get_name : (unit -> string) Core_kernel.Std.Or_error.t

pr_get_name () gets the name of the executing thread. The name is at most 16 bytes long.

Pathname resolution

val file_descr_realpath : (Core_unix.File_descr.t -> string) Core_kernel.Std.Or_error.t

file_descr_realpath fd

Returns the canonicalized absolute pathname of the file associated with file descriptor fd.
Raises [Unix_error] on errors.
val out_channel_realpath : (Core_kernel.Std.out_channel -> string) Core_kernel.Std.Or_error.t

out_channel_realpath oc

Returns the canonicalized absolute pathname of the file associated with output channel oc.
Raises [Unix_error] on errors.
val in_channel_realpath : (Core_kernel.Std.in_channel -> string) Core_kernel.Std.Or_error.t

in_channel_realpath ic

Returns the canonicalized absolute pathname of the file associated with input channel ic.
Raises [Unix_error] on errors.

Affinity

val sched_setaffinity : (?pid:Core_kernel.Std.Pid.t -> cpuset:int list -> unit -> unit) Core_kernel.Std.Or_error.t

Setting the CPU affinity causes a process to only run on the cores chosen. You can find out how many cores a system has in /proc/cpuinfo. This can be useful in two ways: first, it limits a process to a core so that it won't interfere with processes on other cores. Second, you save time by not moving the process back and forth between CPUs, which sometimes invalidates their cache. See man sched_setaffinity for details.

val sched_setaffinity_this_thread : (cpuset:int list -> unit) Core_kernel.Std.Or_error.t
val cores : (unit -> int) Core_kernel.Std.Or_error.t

cores ()

Returns the number of cores on the machine. This may be different than the number of cores available to the calling process.
val get_terminal_size : (unit -> int * int) Core_kernel.Std.Or_error.t

get_terminal_size ()

Returns (rows, cols), the number of rows and columns of the terminal.
module Priority : sig .. end
Priority.t is what is usually referred to as the "nice" value of a process.
val setpriority : (Priority.t -> unit) Core_kernel.Std.Or_error.t

Set the calling thread's priority in the linux scheduler

val getpriority : (unit -> Priority.t) Core_kernel.Std.Or_error.t

Get the calling thread's priority in the linux scheduler

val get_ipv4_address_for_interface : (string -> string) Core_kernel.Std.Or_error.t

get_ipv4_address_for_interface "eth0" returns the IP address assigned to eth0, or throws an exception if no IP address is configured.

val bind_to_interface : (Core_unix.File_descr.t -> [
| `Any
| `Interface_name of string
] -> unit) Core_kernel.Std.Or_error.t

bind_to_interface fd (`Interface_name "eth0") restricts packets from being received/sent on the given file descriptor fd on any interface other than "eth0". Use bind_to_interface fd `Any to allow traffic on any interface. The bindings are not cumulative; you may only select one interface, or any.

Not to be confused with a traditional BSD sockets API bind() call, this Linux-specific socket option (SO_BINDTODEVICE) is used for applications on multi-homed machines with specific security concerns. For similar functionality when using multicast, see Core_unix.mcast_set_ifname.

module Epoll : sig .. end
epoll() - a linux I/O multiplexer of the same family as select() or poll().