Interface to Linux-specific system calls
sendfile ?pos ?len ~fd sock
sends mmap-able data from file descriptor fd
to
socket sock
using offset pos
and length len
.
EAGAIN
.
fd
gettcpopt_bool sock opt
opt
for socket sock
.
settcpopt_bool sock opt v
sets the current value of the boolean TCP socket option
opt
for socket sock
to value v
.
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.
Some
bytes_written
or None
if the operation would have blocked.
String.length buf - pos
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.
String.length buf - pos
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.
Some bytes_written
or
None
if the operation would have blocked.
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.
pr_get_pdeathsig ()
get the signal that will be sent to the currently executing
process when its parent dies.
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.
pr_get_name ()
gets the name of the executing thread. The name is at most 16
bytes long.
file_descr_realpath fd
fd
.
out_channel_realpath oc
oc
.
in_channel_realpath ic
ic
.
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.
cores ()
get_terminal_size ()
(rows, cols)
, the number of rows and
columns of the terminal.
Priority.t
is what is usually referred to as the "nice" value of a process.
get_ipv4_address_for_interface "eth0"
returns the IP address assigned to eth0, or
throws an exception if no IP address is configured.
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.Core_unix.mcast_set_ifname.