wilton/process
OS process operations.
More...
Functions | |
Number | currentPid (Function|Undefined callback) |
Return the PID of the current process. | |
String | killByPid (Number pid, Function|Undefined callback) |
Kill the process with the specified PID. | |
Number | spawn (Object options, Function|Undefined callback) |
Spawn new OS-level process. | |
Number | spawnShell (Array commands, Function|Undefined callback) |
Spawn new OS-level shell process. |
This module currently provides only one function: spawn()
.
Usage example:
Number process::currentPid | ( | Function|Undefined | callback | ) |
Returns the PID of the current process. Not supported on Android.
callback | Function|Undefined callback to receive result or error |
Number
PID of the current process String process::killByPid | ( | Number | pid, |
Function|Undefined | callback | ||
) |
Teminates the process with the specified PID. Target process cannot prevent its termination. Not supported on Android.
pid | Number PID of the process to terminate |
callback | Function|Undefined callback to receive result or error |
String
Empty string on successfull termination, error message otherwise. Number process::spawn | ( | Object | options, |
Function|Undefined | callback | ||
) |
Spawns an OS-level process launching specified executable with the specified arguments.
Spawned process does not have STDIN
connected. STDOUT
and STDERR
are redirected to (the same) specified file.
If awaitExit
flag is enabled - waits for the spawned process to exit and returs its exit code.
Otherwise (default behaviour) returns immediately returning a pid
of the spawned process.
options | Object configuration object, see possible options below |
callback | Function|Undefined callback to receive result or error |
Number
PID of started process or its exit code, if awaitExit
is usedOptions
String
path to the executable fileArray
list of the arguments to provide to the executableString|Undefined
path to the file for the combined STDOUT
and STDERR
outputString|Undefined
path to the working directory for the process, default value: the same working directory as parent processBoolean
whether to wait for the spawned process to exit, false
by default Number process::spawnShell | ( | Array | commands, |
Function|Undefined | callback | ||
) |
Spawns an OS-level shell process launching OS-specific shell processor and waits for it to exit.
Note: use spawn
instead of spawnShell
whether possible.
commands | Array list of commands to pass to OS shell processor |
callback | Function|Undefined callback to receive result or error |
Number
OS-specific output code