Module perc

Copyright © 2012-2020 Michael Santos <michael.santos@gmail.com>

Data Types

int32_t()

int32_t() = -2147483647..2147483647

pid_t()

pid_t() = int32_t()

posix()

posix() = e2big | eacces | eaddrinuse | eaddrnotavail | eadv | eafnosupport | eagain | ealign | ealready | ebade | ebadf | ebadfd | ebadmsg | ebadr | ebadrpc | ebadrqc | ebadslt | ebfont | ebusy | ecapmode | echild | echrng | ecomm | econnaborted | econnrefused | econnreset | edeadlk | edeadlock | edestaddrreq | edirty | edom | edotdot | edquot | eduppkg | eexist | efault | efbig | ehostdown | ehostunreach | eidrm | einit | einprogress | eintr | einval | eio | eisconn | eisdir | eisnam | el2hlt | el2nsync | el3hlt | el3rst | elbin | elibacc | elibbad | elibexec | elibmax | elibscn | elnrng | eloop | emfile | emlink | emsgsize | emultihop | enametoolong | enavail | enet | enetdown | enetreset | enetunreach | enfile | enoano | enobufs | enocsi | enodata | enodev | enoent | enoexec | enolck | enolink | enomem | enomsg | enonet | enopkg | enoprotoopt | enospc | enosr | enostr | enosym | enosys | enotblk | enotcapable | enotconn | enotdir | enotempty | enotnam | enotrecoverable | enotsock | enotsup | enotty | enotuniq | enxio | eopnotsupp | eoverflow | eownerdead | eperm | epfnosupport | epipe | eproclim | eprocunavail | eprogmismatch | eprogunavail | eproto | eprotonosupport | eprototype | erange | erefused | eremchg | eremdev | eremote | eremoteio | eremoterelease | erofs | erpcmismatch | erremote | eshutdown | esocktnosupport | espipe | esrch | esrmnt | estale | esuccess | etime | etimedout | etoomanyrefs | etxtbsy | euclean | eunatch | eusers | eversion | ewouldblock | exdev | exfull

priority()

priority() = int32_t() | {pid, int32_t()} | {pgrp, int32_t()} | {user, int32_t()}

uint32_t()

uint32_t() = 0..4294967295

uint64_t()

uint64_t() = 0..18446744073709551615

Function Index

close/1
getpriority/2getpriority(2): get the process priority.
getrlimit/1getrlimit(2): get process resource limits.
getumask/0getumask(3): safer version of umask/0.
kill/2kill(2): send a signal to a Unix process.
prctl/3
prlimit/4prlimit(2): set resource limits for a specified process.
renice/2renice: reset the process priority.
setpriority/3setpriority(2): set the process priority.
setrlimit/2setrlimit(2): set process resource limits.
sigaddset/1
signalfd/1
signalfd/2
status/0status: retrieve process status.
umask/0umask(2): get the process mask.
umask/1umask(2): set the process mask.

Function Details

close/1

close(X1::int32_t()) -> ok | {error, posix()}

getpriority/2

getpriority(X1::int32_t(), X2::int32_t()) -> {ok, int32_t()} | {error, posix()}

getpriority(2): get the process priority

Get the priority (the "nice" value) of processes by pid, process group or user.

getrlimit/1

getrlimit(Resource::atom() | int32_t()) -> {ok, binary()} | {error, posix()}

getrlimit(2): get process resource limits

Get process limits for beam. See prlimit/4 for a list of the resource atoms.

The value returned is a struct rlimit:

  1> {ok, <<Soft:8/native-unsigned-integer-unit:8, Hard:8/native-unsigned-integer-unit:8>>} = perc:getrlimit(rlimit_nofile).
  2> Soft.
  1024
  3> Hard.
  4096

getumask/0

getumask() -> int32_t()

getumask(3): safer version of umask/0

Obtain the current process mask by parsing /proc/self/status, avoiding the race condition in umask/0.

If /proc/self/status does not exist or is not parsable, getumask/0 fails back to umask/0.

kill/2

kill(Pid::pid_t(), Signal::atom() | integer()) -> ok | {error, posix()}

kill(2): send a signal to a Unix process

Process IDs and signals are signed 32-bit integers. A signal can also be the lower cased signal name as an atom.

Sending a signal to PID 0 will send the signal to the Erlang VM.

prctl/3

prctl(X1::int32_t(), X2::uint32_t() | uint64_t(), X3::binary()) -> ok | {error, posix()}

prlimit/4

prlimit(Pid::pid_t(), Resource::atom() | int32_t(), New::binary(), Old::binary()) -> {ok, binary(), binary()} | {error, posix()}

prlimit(2): set resource limits for a specified process

Linux only: on other platforms, {error, unsupported} will be returned to the caller.

Set or retrieve process limits for a process. Passing in an empty binary for NewLimit or OldLimit indicates the caller is not interested in these values.

The binary size of NewLimit/OldLimit must otherwise match the size of a struct rlimit for the platform. struct rlimit is usually composed of two 8 byte values in native format. To retrieve the current settings, pass in a zeroed 16 byte value.

renice/2

renice(Type::priority(), Priority::string() | int32_t()) -> ok | {error, posix()}

renice: reset the process priority

Convenience wrapper around getpriority/2 and setpriority/3, similar to renice(1).

WARNING: renice/2 makes successive calls to getpriority/2 and setpriority/3. Since this sequence is not atomic, the priority may change between calls or the process may have been terminated.

Sets the priority of a process or processes by pid, pgroup or user. The new priority may be an integer or a list containing a relative priority, indicated by using a "+" or "-". For example, using "+10" will increase the niceness of the process by 10.

setpriority/3

setpriority(X1::int32_t(), X2::int32_t(), X3::int32_t()) -> ok | {error, posix()}

setpriority(2): set the process priority

Set the priority (the "nice" value) of processes by pid, process group or user.

setrlimit/2

setrlimit(Resource::atom() | int32_t(), Limit::atom() | int32_t()) -> {ok, binary()} | {error, posix()}

setrlimit(2): set process resource limits

Set process limits for beam. See prlimit/4 for a list of the resource atoms.

sigaddset/1

sigaddset(Signals::[atom() | int32_t()]) -> {ok, binary()} | {error, posix()}

signalfd/1

signalfd(Mask::binary()) -> {ok, int32_t()} | {error, posix()}

signalfd/2

signalfd(Fd::int32_t(), Mask::binary()) -> {ok, int32_t()} | {error, posix()}

status/0

status() -> {ok, #{binary() => binary()}} | {error, atom()}

status: retrieve process status

Reads /proc/self/status as a map.

umask/0

umask() -> int32_t()

umask(2): get the process mask

WARNING: umask/0 is destructive: the umask is retrieved by setting the process mask to 0, then re-setting it back to the original mask. Between the successive calls to umask(2), the process mask is 0. An erlang process calling umask/0 concurrently with a process creating a file may have unexpected results.

umask/1

umask(Mask::string() | int32_t()) -> int32_t()

umask(2): set the process mask

Sets the file creation mask for beam. The mask may be either an integer or a list representing an octal number, e.g., either 8#022 or "022".

The old mask value is returned. To retrieve the current umask, use umask/0 or getumask/0.


Generated by EDoc