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: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 to redirect from.

Returns:

    this ProcessBuilder
processBuilder:getRedirectOutput ()
Returns the process standard output redirection.

Returns:

    the redirection
processBuilder:setRedirectOutput (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:getRedirectError ()
Returns the process standard error redirection.

Returns:

    the redirection
processBuilder:setRedirectError (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 (callback)
Starts this ProcessBuilder.

Parameters:

  • callback

Returns:

    jls.lang.ProcessHandle The handle of the new process
generated by LDoc 1.4.6 Last updated 2022-01-22 16:32:56