Module Core.Linux_ext
Interface to Linux-specific system calls.
module Sysinfo : sig ... endFilesystem functions
val sendfile : (?pos:int -> ?len:int -> fd:Core__.Core_unix.File_descr.t -> Core__.Core_unix.File_descr.t -> int) Core__.Import.Or_error.tsendfile ?pos ?len ~fd socksends mmap-able data from file descriptorfdto socketsockusing offsetposand lengthlen. 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 may have occurred on the socket during sending. It is currently impossible to find out which of these events actually happened. Calling
sendfileseveral times on the same descriptor that only partially accepted data due to a timeout will eventually lead to the Unix errorEAGAIN.Raises
Unix_erroron Unix-errors.
module Bound_to_interface : sig ... endType for status of SO_BINDTODEVICE socket option. The socket may either restrict the traffic to a given (by name, e.g. "eth0") interface, or do no restriction at all.
Non-portable TCP functionality
type tcp_bool_option=
val sexp_of_tcp_bool_option : tcp_bool_option -> Ppx_sexp_conv_lib.Sexp.tval tcp_bool_option_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> tcp_bool_optionval bin_shape_tcp_bool_option : Bin_prot.Shape.tval bin_size_tcp_bool_option : tcp_bool_option Bin_prot.Size.sizerval bin_write_tcp_bool_option : tcp_bool_option Bin_prot.Write.writerval bin_writer_tcp_bool_option : tcp_bool_option Bin_prot.Type_class.writerval bin_read_tcp_bool_option : tcp_bool_option Bin_prot.Read.readerval __bin_read_tcp_bool_option__ : (int -> tcp_bool_option) Bin_prot.Read.readerval bin_reader_tcp_bool_option : tcp_bool_option Bin_prot.Type_class.readerval bin_tcp_bool_option : tcp_bool_option Bin_prot.Type_class.t
val gettcpopt_bool : (Core__.Core_unix.File_descr.t -> tcp_bool_option -> bool) Core__.Import.Or_error.tgettcpopt_bool sock optReturns the current value of the boolean TCP socket optionoptfor socketsock.
val settcpopt_bool : (Core__.Core_unix.File_descr.t -> tcp_bool_option -> bool -> unit) Core__.Import.Or_error.tsettcpopt_bool sock opt vsets the current value of the boolean TCP socket optionoptfor socketsockto valuev.
val send_nonblocking_no_sigpipe : (Core__.Core_unix.File_descr.t -> ?pos:int -> ?len:int -> Core__.Import.Bytes.t -> int option) Core__.Import.Or_error.tsend_nonblocking_no_sigpipe sock ?pos ?len buftries to do a nonblocking send on socketsockgiven bufferbuf, offsetposand lengthlen. PreventsSIGPIPE, i.e., raises a Unix-error in that case immediately. ReturnsSome bytes_writtenorNoneif the operation would have blocked.Raises
Invalid_argumentif the designated buffer range is invalid. RaisesUnix_erroron Unix-errors.
val send_no_sigpipe : (Core__.Core_unix.File_descr.t -> ?pos:int -> ?len:int -> Core__.Import.Bytes.t -> int) Core__.Import.Or_error.tsend_no_sigpipe sock ?pos ?len buftries to do a blocking send on socketsockgiven bufferbuf, offsetposand lengthlen. PreventsSIGPIPE, i.e., raises a Unix-error in that case immediately. Returns the number of bytes written.Raises
Invalid_argumentif the designated buffer range is invalid. RaisesUnix_erroron Unix-errors.
val sendmsg_nonblocking_no_sigpipe : (Core__.Core_unix.File_descr.t -> ?count:int -> string Core__.Core_unix.IOVec.t array -> int option) Core__.Import.Or_error.tsendmsg_nonblocking_no_sigpipe sock ?count iovecstries to do a nonblocking send on socketsockusingcountI/O-vectorsiovecs. PreventsSIGPIPE, i.e., raises a Unix-error in that case immediately. ReturnsSome bytes_writtenorNoneif the operation would have blocked.Raises
Invalid_argumentif the designated ranges are invalid. RaisesUnix_erroron Unix-errors.
Clock functions
module Clock : sig ... endEventfd functions
module Eventfd : sig ... endTimerfd functions
module Timerfd : sig ... endParent death notifications
val pr_set_pdeathsig : (Signal.t -> unit) Core__.Import.Or_error.tpr_set_pdeathsig ssets the signalsto 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 callgetppidto 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 usingUnix.kill, or execute an appropriate handler.
val pr_get_pdeathsig : (unit -> Signal.t) Core__.Import.Or_error.tpr_get_pdeathsig ()gets 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__.Import.Or_error.tpr_set_name_first16 namesets the name of the executing thread toname. Only the first 16 bytes innamewill be used; the rest is ignored.
val pr_get_name : (unit -> string) Core__.Import.Or_error.tpr_get_name ()gets the name of the executing thread. The name is at most 16 bytes long.
Pathname resolution
val file_descr_realpath : (Core__.Core_unix.File_descr.t -> string) Core__.Import.Or_error.tfile_descr_realpath fdreturns the canonicalized absolute pathname of the file associated with file descriptorfd.Raises
Unix_erroron errors.
val out_channel_realpath : (Core__.Import.Out_channel.t -> string) Core__.Import.Or_error.tout_channel_realpath ocreturns the canonicalized absolute pathname of the file associated with output channeloc.Raises
Unix_erroron errors.
val in_channel_realpath : (Core__.Import.In_channel.t -> string) Core__.Import.Or_error.tin_channel_realpath icreturns the canonicalized absolute pathname of the file associated with input channelic.Raises
Unix_erroron errors.
Affinity
val sched_setaffinity : (?pid:Core__.Import.Pid.t -> cpuset:int list -> unit -> unit) Core__.Import.Or_error.tSetting 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_setaffinityfor details.
val sched_getaffinity : (?pid:Core__.Import.Pid.t -> unit -> int list) Core__.Import.Or_error.tval sched_setaffinity_this_thread : (cpuset:int list -> unit) Core__.Import.Or_error.tval cores : (unit -> int) Core__.Import.Or_error.tcores ()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 : ([ `Controlling | `Fd of Core__.Core_unix.File_descr.t ] -> int * int) Core__.Import.Or_error.tget_terminal_size termreturns(rows, cols), the number of rows and columns of the controlling terminal (raises if no controlling terminal), or of the specified file descriptor (useful when writing to stdout, because stdout doesn't have to be the controlling terminal).
module Priority : sig ... endPriority.tis what is usually referred to as the "nice" value of a process. It is also known as the "dynamic" priority. It is used with normal (as opposed to real-time) processes that have static priority zero. SeeUnix.Scheduler.setfor setting the static priority.
val setpriority : (Priority.t -> unit) Core__.Import.Or_error.tSet the calling thread's priority in the Linux scheduler
val getpriority : (unit -> Priority.t) Core__.Import.Or_error.tGet the calling thread's priority in the Linux scheduler
val get_ipv4_address_for_interface : (string -> string) Core__.Import.Or_error.tget_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__.Core_unix.File_descr.t -> Bound_to_interface.t -> unit) Core__.Import.Or_error.tbind_to_interface fd (Only "eth0")restricts packets from being received/sent on the given file descriptorfdon any interface other than "eth0". Usebind_to_interface fd Anyto allow traffic on any interface. The bindings are not cumulative; you may only select one interface, orAny.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, seeCore_unix.mcast_set_ifname.
val get_bind_to_interface : (Core__.Core_unix.File_descr.t -> Bound_to_interface.t) Core__.Import.Or_error.t
module Epoll : sig ... endepoll(): a Linux I/O multiplexer of the same family as select() or poll(). Its main differences are support for Edge- or Level-triggered notifications (we're using Level-triggered to emulate "select") and much better scaling with the number of file descriptors.
module Extended_file_attributes : sig ... end