Stdio.Syscall behaviour (stdio v0.1.0)

System call portability for operating systems.

Link to this section Summary

Callbacks

Operations required to disable setuid.

Path to procfs file system

Terminate descendents of a supervisor process.

Terminate a process subtree (descendents of a child process) of the supervisor.

Operations required to terminate a process if the parent exits.

Set the process title.

Set process as init(1) for descendent processes.

Functions

The default implementation for disable_setuid/0

Get the syscall implementation for this platform.

The default implementation for procfs/0

Terminating descendents of a supervisor process

Terminate descendents of a process.

The default implementation for set_pdeathsig/0

The default implementation for setproctitle/2

The default implementation for subreaper/1

Link to this section Callbacks

Link to this callback

disable_setuid()

@callback disable_setuid() :: [Stdio.Op.t()]

Operations required to disable setuid.

@callback procfs() :: String.t()

Path to procfs file system

Link to this callback

reap(task, atom)

@callback reap(:prx.task(), atom()) :: :ok | {:error, :prx.posix()}

Terminate descendents of a supervisor process.

Link to this callback

reap(task, pid_t, atom)

@callback reap(:prx.task(), :prx.pid_t(), atom()) :: :ok | {:error, :prx.posix()}

Terminate a process subtree (descendents of a child process) of the supervisor.

Link to this callback

set_pdeathsig()

@callback set_pdeathsig() :: [Stdio.Op.t()]

Operations required to terminate a process if the parent exits.

Link to this callback

setproctitle(task, t)

@callback setproctitle(:prx.task(), String.t()) :: :ok | {:error, :prx.posix()}

Set the process title.

Link to this callback

subreaper(task)

@callback subreaper(:prx.task()) :: :ok | {:error, :prx.posix()}

Set process as init(1) for descendent processes.

Link to this section Functions

Link to this function

disable_setuid()

The default implementation for disable_setuid/0

Disabling the ability for the process to escalate privileges is not available on this platform.

@spec os() :: module()

Get the syscall implementation for this platform.

The default implementation is based on the operating system.

Set the implementation by configuring the application environment:

import Config

config :stdio, :syscall, Stdio.Syscall.Linux

The default implementation for procfs/0

Link to this function

reap(task, signal)

Terminating descendents of a supervisor process

Link to this function

reap(task, pid, signal)

Terminate descendents of a process.

reap signals subprocesses of a process identified by PID. If the process called PR_SET_CHILD_SUBREAPER, background and daemonized subprocesses will also be terminated.

Note: terminating subprocesses using this method is subject to race conditions:

  • new processes may have been forked

  • processes may have exited and unrelated processes assigned the PID

  • processes may ignore some signals

  • processes may not immediately exit after signalling

Link to this function

set_pdeathsig()

The default implementation for set_pdeathsig/0

Signalling a process when the parent has exited is not available on this platform.

Link to this function

setproctitle(task, title)

The default implementation for setproctitle/2

Uses :prx.setproctitle/2 on all platforms.

Link to this function

subreaper(task)

The default implementation for subreaper/1

No changes are made to the process: background processes will not be terminated.