Module jls.lang.ProcessBuilder

Enables to create a native process.

Note: The full implementation is only available with libuv

Class ProcessBuilder

ProcessBuilder:new (...) Creates a new ProcessBuilder.
processBuilder:command (...) Sets the process executable path and arguments.
processBuilder:getDirectory () Returns the process working directory.
processBuilder:setDirectory (dir) Sets the process working directory.
processBuilder:getEnvironment () Returns the process environment.
processBuilder:setEnvironment (env) Sets the process environment.
processBuilder:getRedirectInput () Returns the process standard input redirection.
processBuilder:setRedirectInput ([fd]) Redirects the process standard input.
processBuilder:getRedirectOutput () Returns the process standard output redirection.
processBuilder:setRedirectOutput ([fd]) Redirects the process standard output.
processBuilder:getRedirectError () Returns the process standard error redirection.
processBuilder:setRedirectError ([fd]) Redirects the process standard error.
processBuilder:start (callback) Starts this ProcessBuilder.


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:getDirectory ()
Returns the process working directory.

Returns:

    string The process working directory or nil
processBuilder:setDirectory (dir)
Sets the process working directory.

Parameters:

  • dir string The process working directory

Returns:

    This ProcessBuilder
processBuilder:getEnvironment ()
Returns the process environment.

Returns:

    table The process environment
processBuilder:setEnvironment (env)
Sets the process environment.

Parameters:

  • env table The process environment

Returns:

    This ProcessBuilder
processBuilder:getRedirectInput ()
Returns the process standard input redirection.

Returns:

    The redirection
processBuilder:setRedirectInput ([fd])
Redirects the process standard input.

Parameters:

  • fd The file descriptor or pipe to redirect from (optional)

Returns:

    This ProcessBuilder

Usage:

    pb:setRedirectInput(system.input)
processBuilder:getRedirectOutput ()
Returns the process standard output redirection.

Returns:

    The redirection
processBuilder:setRedirectOutput ([fd])
Redirects the process standard output. If not provided, the standard output will be discarded, redirected to null.

Parameters:

  • fd The file descriptor or pipe to redirect to (optional)

Returns:

    This ProcessBuilder

Usage:

    local fd = FileDescriptor.openSync(tmpFile, 'w')
    local pb = ProcessBuilder:new({'lua', '-e', 'io.write("Hello")'})
    pb:setRedirectOutput(fd)
    pb:setRedirectError(system.error) -- use standard error
processBuilder:getRedirectError ()
Returns the process standard error redirection.

Returns:

    the redirection
processBuilder:setRedirectError ([fd])
Redirects the process standard error.

Parameters:

  • fd The file descriptor or pipe to redirect to (optional)

Returns:

    This ProcessBuilder

Usage:

    local pb = ProcessBuilder:new({'lua', '-e', 'io.stderr:write("Hello")'})
    local pipe = Pipe:new()
    pb:setRedirectError(pipe)
processBuilder:start (callback)
Starts this ProcessBuilder.

Parameters:

  • callback

Returns:

    jls.lang.ProcessHandle The handle of the new process
generated by LDoc 1.4.6