View Source Stdio.Syscall behaviour (stdio v0.2.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

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

Operations required to disable setuid.

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

Path to procfs file system

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

Terminate descendents of a supervisor process.

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

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

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

Operations required to terminate a process if the parent exits.

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

Set the process title.

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

Set process as init(1) for descendent processes.

Link to this section Functions

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

Terminating descendents of a supervisor process

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

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)

View Source

The default implementation for setproctitle/2

Uses :prx.setproctitle/2 on all platforms.

The default implementation for subreaper/1

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