Procman - The-Riddler/CCKernel GitHub Wiki
Purpose
Procman is the systems 'process' manager, there is a number of definitions that will help with understanding the workings of the system:
- For the purposes of this a 'process' is any file containing a Lua script that is currently running.
- An 'event' is a return (and the information) from 'os.pullEvent()'
- A 'hook' is a function attached to an 'event'. These are process specific and are not limited to one per event.
- A 'one-shot' process is a process that does not wish to execute code beyond its initial execution, examples of this type of program are ls.lua, mkdir.lua and rm.lua.
- A processes 'PID' is the handle for the process that is used to refer to it.
Commands
Procman supports the following commands:
Run
The run command sets up the process info data, allocates a handle for it and executes the code. It returns status code telling you what happened, if it worked, if it failed, why it failed and if it was a one-shot process.
#Arguments Run takes 4 direct arguments (aimed at the run function) and then a variable number of arguments which will be passed to the called process. These are as follows:
- path - the path to the Lua file containing the code
- name - the name you wish to call this process, if not supplied it will default to the name supplied by the process, if it is not supplied there either it will default to the processes PID.
- environment - the environment the called process will be given. If not given will default to the environment of the function that called run.
- background - If this is set to false (explicitly) the calling process will be suspended from further execution until the newly spawned process returns. This defaults to true (i.e the new process does run in the background). It is important to note that currently there is no custom I/O in place and a background process can still write and read events. If processes are not designed with this in mind it can cause issues. A sort of "stream" feature is planned for the future.
#Return The run command will return a status code indicating how the execution went and a return value or more detailed error message (if applicable).
#Statuscodes (taken from procman.lua)
statuscodes.STAT_OK = 0
statuscodes.STAT_404 = 1
statuscodes.STAT_CALL = 2
statuscodes.STAT_LOAD = 3
statuscodes.STAT_OK_RET = 4
statuscodes.STAT_DATAERROR = 5
statuscodes.STAT_ALLOCPID = 6