Module jls.lang.ProcessBuilder
This class enables to create a native process.
Note: The only full implementation is based on libuv
Class ProcessBuilder
ProcessBuilder:new (...) | Creates a new ProcessBuilder. |
processBuilder:command (...) | Sets the process executable path and arguments. |
processBuilder:directory (dir) | Sets the process working directory. |
processBuilder:environment (env) | Sets the process environment. |
processBuilder:redirectInput (fd) | Redirects the process standard input. |
processBuilder:redirectOutput (fd) | Redirects the process standard output. |
processBuilder:redirectError (fd) | Redirects the process standard error. |
processBuilder:start ([onexit]) | Starts this ProcessBuilder. |
ProcessBuilder.getExecutablePath () | Returns the current working directory. |
Class ProcessBuilder
A ProcessBuilder class.
- ProcessBuilder:new (...)
-
Creates a new ProcessBuilder.
Parameters:
- ... string the process executable path and arguments
Returns:
-
a new ProcessBuilder
Usage:
local pb = ProcessBuilder:new('ls', '-ltr') pb:start()
- processBuilder:command (...)
-
Sets the process executable path and arguments.
With no parameter the function returns the process executable path and arguments.
Parameters:
- ... string the process executable path and arguments as strings
Returns:
-
this ProcessBuilder
- processBuilder:directory (dir)
-
Sets the process working directory.
With no parameter the function returns the process working directory.
Parameters:
- dir string the process working directory.
Returns:
-
this ProcessBuilder
- processBuilder:environment (env)
-
Sets the process environment.
With no parameter the function returns the process environment.
Parameters:
- env table the process environment.
Returns:
-
this ProcessBuilder
- processBuilder:redirectInput (fd)
-
Redirects the process standard input.
With no parameter the function returns the redirection.
Parameters:
- fd the file descriptor to redirect from.
Returns:
-
this ProcessBuilder
- processBuilder:redirectOutput (fd)
-
Redirects the process standard output.
With no parameter the function returns the redirection.
Parameters:
- fd the file descriptor to redirect to.
Returns:
-
this ProcessBuilder
Usage:
local fd = FileDescriptor.openSync(tmpFile, 'w') local pb = ProcessBuilder:new({'lua', '-e', 'io.write("Hello")'}) pb:redirectOutput(fd)
- processBuilder:redirectError (fd)
-
Redirects the process standard error.
With no parameter the function returns the redirection.
Parameters:
- fd the file descriptor to redirect to.
Returns:
-
this ProcessBuilder
Usage:
local pb = ProcessBuilder:new({'lua', '-e', 'io.stderr:write("Hello")'}) local pipe = Pipe:new() pb:redirectError(pipe)
- processBuilder:start ([onexit])
-
Starts this ProcessBuilder.
Parameters:
- onexit function A function that will be called with the exit code when the process ended. (optional)
Returns:
-
jls.lang.ProcessHandle
The handle of the new process
- ProcessBuilder.getExecutablePath ()
-
Returns the current working directory.
Returns:
-
string
the current working directory.