perc (perc v1.0.1) View Source

Link to this section Summary

Functions

getegid(2): get effective group id
geteuid(2): get effective user id
getgid(2): get group identity
getgroups(2): retrieve the list of supplementary groups

getpriority(2): get the process priority

getrlimit(2): get process resource limits

getuid(2): get user identity

getumask(3): safer version of umask/0

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

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

renice: reset the process priority

setgroups(2): set the list of supplementary groups

setpriority(2): set the process priority

setresgid(2): set real, effective and saved group id
setresuid(2): set real, effective and saved user id

setrlimit(2): set process resource limits

status: retrieve process status

umask(2): get the process mask

umask(2): set the process mask

Link to this section Types

Specs

int32_t() :: - 2147483647..2147483647.

Specs

pid_t() :: int32_t().

Specs

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.

Specs

priority() :: int32_t() | {pid, int32_t()} | {pgrp, int32_t()} | {user, int32_t()}.

Specs

uint32_t() :: 0..4294967295.

Specs

uint64_t() :: 0..18446744073709551615.

Link to this section Functions

Specs

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

Specs

getegid() -> uint32_t().
getegid(2): get effective group id

Specs

geteuid() -> uint32_t().
geteuid(2): get effective user id

Specs

getgid() -> uint32_t().
getgid(2): get group identity

Specs

getgroups() -> [uint32_t()].
getgroups(2): retrieve the list of supplementary groups

Specs

getpriority(int32_t(), 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.

Specs

getrlimit(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

Specs

getuid() -> uint32_t().
getuid(2): get user identity

Specs

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.

Specs

kill(pid_t(), 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.

Specs

prctl(int32_t(), uint32_t() | uint64_t(), binary()) -> ok | {error, posix()}.
Link to this function

prlimit(Pid, Resource, New, Old)

View Source

Specs

prlimit(pid_t(), atom() | int32_t(), binary(), 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.

Specs

renice(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.

Specs

setgroups([uint32_t()]) -> ok | {error, posix()}.
setgroups(2): set the list of supplementary groups

Specs

setpriority(int32_t(), int32_t(), 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.

Specs

setresgid(uint32_t(), uint32_t(), uint32_t()) -> ok | {error, posix()}.
setresgid(2): set real, effective and saved group id

Specs

setresuid(uint32_t(), uint32_t(), uint32_t()) -> ok | {error, posix()}.
setresuid(2): set real, effective and saved user id
Link to this function

setrlimit(Resource, Limit)

View Source

Specs

setrlimit(atom() | int32_t(), 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.

Specs

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

Specs

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

Specs

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

Specs

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

status: retrieve process status

Reads /proc/self/status as a map.

Specs

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.

Specs

umask(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.