Module tasks

User library allowing to create and manage processes.

Functions

getCurrentProcess () Returns the current process object or nil if no process is active (only the case during boot)
sleep (secs) Pause the current process for the specified number of seconds
getProcess (pid) Get the process object corresponding to the given PID.
waitFor (proc) Pause the current process until the given process has ended
kill (proc) Kill the given process, calling the safe kill handler if present
unsafeKill (proc) Kill the given process without accounting for the safe kill handler.
getProcessMetrics (pid) Returns the process metrics from the given PID
getPIDs () Returns the list of PIDs used by living processes
getProcesses () Returns the list of all living process objects
newProcess (name, func) Spawns and starts a new process

Class process

process.name The name of the process
process.func The coroutine function of the process
process.pid The PID of the process.
process.status The status of the process, can be one of "created", "running", "sleeping" or "wait_signal"
process:detach () Detach the given process, that is make it an orphan process (with no parent)
process:kill () Kill the given process


Functions

getCurrentProcess ()
Returns the current process object or nil if no process is active (only the case during boot)

Returns:

    process object
sleep (secs)
Pause the current process for the specified number of seconds

Parameters:

  • secs Seconds to wait

See also:

getProcess (pid)
Get the process object corresponding to the given PID.

Required permissions:

    scheduler.list or process.edit

Parameters:

  • pid PID of the process

Returns:

    process object
waitFor (proc)
Pause the current process until the given process has ended

Parameters:

  • proc Process to wait for

See also:

kill (proc)
Kill the given process, calling the safe kill handler if present

Parameters:

  • proc process object
unsafeKill (proc)
Kill the given process without accounting for the safe kill handler.

Parameters:

  • proc process object
getProcessMetrics (pid)
Returns the process metrics from the given PID

Parameters:

  • pid pid of process

Returns:

    process metrics
getPIDs ()
Returns the list of PIDs used by living processes

Returns:

    number[] all PIDs
getProcesses ()
Returns the list of all living process objects

Required permissions:

    scheduler.list

Returns:

    process[] all process objects
newProcess (name, func)
Spawns and starts a new process

Parameters:

  • name The name of the process
  • func The function to be called as process

Returns:

    process process object

Class process

A process object.
process.name
The name of the process
process.func
The coroutine function of the process
process.pid
The PID of the process. It's a reliable pointer to process that help know if a process is dead
process.status
The status of the process, can be one of "created", "running", "sleeping" or "wait_signal"
process:detach ()
Detach the given process, that is make it an orphan process (with no parent)
process:kill ()
Kill the given process
generated by LDoc 1.4.6 Last updated 2021-12-27 19:58:59