-
Notifications
You must be signed in to change notification settings - Fork 435
API Process
Vexatos edited this page Jul 13, 2014
·
2 revisions
For those that don't like images: the wiki has moved to a new place, http://ocdoc.cil.li/.
This wiki will no longer be updated.
This API provides rudimentary process management. It is used mainly by the io
module to provide individual standard input and output to individual programs.
-
process.load(path:string[, env:table[, init:function[, name:string]]]):coroutine
Loads a Lua script from the specified absolute path and sets it up as a process.
It will be loaded with a custom environment, to avoid cluttering the callers/global environment. This environment will have access to anything in the specified environment, or the default (top level) environment if none is given.
If aninit
function is specified, that method is called the first time the resulting coroutine is executed, and run before the actual program is started. This allows fine-tuning of the programs environment.
If aname
is specified, that is the name the process will specify inprocess.running
. It will benil
otherwise. -
process.running([level: number]): string, table, string
Returns the path to the currently running program (i.e. the last process created viaprocess.load
). The level can optionally be provided to get parent processes. It defaults to 1, the current program. 2 is the current program's parent (the one that calledprocess.load
to start the current program) and so on.
The second returned value is the environment of the process, i.e. the table created for it to use as one.
The third returned value is the 'name' of the process, i.e. the fourth parameter toprocess.load
. For programs started via the shell this will ususally be the original command. E.g. forls -l
, the first returned value will bels
, while this value will bels -l
.