Docs / Plugins / Plugin API reference
External programs
omsi.process.* starts native helper programs from the plugin's own folder. Every helper needs the player's approval first, see Native helper programs.
omsi.process.exit_code#
omsi.process.exit_code(handle) → code or nil, state or reason
Nonblocking exit code lookup (queued verification also counts as running): nil, "running" while running; code, "exited" after normal exit. A nonzero code is retained. Signal termination returns nil, "exited"; inspect process.status for details. Preparation failure returns nil, "failed", reason. An unknown handle returns nil and a reason.
Parameters: handle integer.
Since unreleased. Permission: process.
omsi.process.forget#
omsi.process.forget(handle) → true, or nil and reason
Release a completed or failed process handle and its retained result. A running process cannot be forgotten. On Windows, closing its job also terminates any remaining descendants.
Parameters: handle integer.
Since unreleased. Permission: process.
omsi.process.kill#
omsi.process.kill(handle) → true, or nil and reason
Cancel a queued start or request termination of a plugin-owned direct child without waiting. Poll process.status for completion; Windows also terminates the job descendants, Unix targets only the direct child.
Parameters: handle integer.
Since unreleased. Permission: process.
omsi.process.start#
omsi.process.start(file, [args], [options]) → handle, or nil and reason
Queue a native helper without waiting; return a reserved handle immediately. The interactive game asks the player with Allow once, Always allow or Deny unless the exact content was already approved. Embedded hosts without a permission broker remain default-deny.
Verification and OS process creation run on two shared workers with at most 32 globally queued starts. The 32-handle plugin limit (including queued and failed starts) is checked before admission. A full queue returns nil and a reason.
Accepted starts can fail later: inspect status.error or exit_code/wait returning nil, failed, reason. file must be a relative path inside the plugin folder. Approval is bound to the entry, folder snapshot and helper SHA256.
Allow once covers one launch; Always allow saves consent in the host user settings; Deny blocks all native helpers for this canonical plugin entry for the current session, including renamed helpers or changed content or arguments. Changed content needs new approval.
While the dialog is open, preparation workers and child cleanup keep running. The entry, executable-content snapshot (including importable Lua modules and native libraries), and helper hashes are rechecked on the worker immediately before each start; code changes revoke consent, while ordinary save/data writes do not.
args are separate literal strings without shell expansion. Options: cwd and env (string overrides, other variables inherited, except OMSI_PLUGIN_PROCESS_ALLOW is always removed). Standard streams are disconnected. Windows helpers must be .exe files. At most 32 handles per plugin; forget completed handles.
Stop, disable and reload terminate children; Windows job objects also terminate descendants and survive abrupt game exit, Linux uses a parent-death signal for direct children. No native helper runs before player approval. OMSI_PLUGIN_PROCESS_ALLOW can optionally name an absolute JSON grant manifest for preapproved content.
Packages must also declare process. Unload/reload cancels unanswered requests. Approved helpers run with the game account's permissions.
Parameters: file string; args table, optional; options table, optional.
Since unreleased. Permission: process.
local h, why = omsi.process.start("bin/helper.exe", { "--fast" })
if h then
local code, state = omsi.process.wait(h)
omsi.process.forget(h)
endomsi.process.status#
omsi.process.status(handle) → table, or nil and reason
Nonblocking status: {pid, starting, awaiting_permission, running, exited, failed, error, code, success, signal}. While verification/start is pending, starting and running are true and pid is nil. Failed preparation sets failed/error without an exit code. While running code, success and signal are nil.
After exit code is the exit code (including nonzero); termination by a signal has no code, and signal is available on Unix. Results remain readable until forgotten.
Parameters: handle integer.
Since unreleased. Permission: process.
omsi.process.wait#
omsi.process.wait(handle) → exit code or nil, state or reason
Lua: suspend this plugin through queued verification/start and until its direct child exits, then return code, "exited" (nonzero codes retained; nil code on signal exit). The game and other plugins keep running; no game-thread wait occurs. Works in the main chunk, start/frame/event handlers and timers.
Queued callbacks resume afterwards (limit 256), and normal frames/timers pause during the wait. Stop/reload cancels the continuation and terminates the child. A nested emit callback or manually resumed coroutine cannot suspend. Preparation failure returns nil, "failed", reason. Other language bindings should poll process.exit_code instead.
Parameters: handle integer.
Since unreleased. Permission: process.
Something wrong or missing? Fix it on GitHub or open an issue.