Interface Process


  • public interface Process
    A process launched from this current process.

    Please see the user manual for more detailed usage information.

    Author:
    Julien Viet
    • Method Detail

      • env

        static Map<String,​String> env()
        Returns:
        the current process environment variables
      • create

        static ProcessBuilder create​(Vertx vertx,
                                     String command)
        Create a child process (not running) from this process, call ProcessBuilder.start() to start the process.
        Parameters:
        vertx - the vertx instance
        command - the command to run
        Returns:
        the created child process
      • create

        static ProcessBuilder create​(Vertx vertx,
                                     String command,
                                     List<String> args)
        Create a child process (not running) from this process, call ProcessBuilder.start() to start the process.
        Parameters:
        vertx - the vertx instance
        command - the command to run
        args - list of string arguments
        Returns:
        the created child process
      • create

        static ProcessBuilder create​(Vertx vertx,
                                     String command,
                                     ProcessOptions options)
        Create a child process (not running) from this process, call ProcessBuilder.start() to start the process.
        Parameters:
        vertx - the vertx instance
        command - the command to run
        options - the options to run the command
        Returns:
        the created child process
      • create

        static ProcessBuilder create​(Vertx vertx,
                                     String command,
                                     List<String> args,
                                     ProcessOptions options)
        Create a child process (not running) from this process, call ProcessBuilder.start() to start the process.
        Parameters:
        vertx - the vertx instance
        command - the command to run
        args - list of string arguments
        options - the options to run the command
        Returns:
        the created child process
      • exitHandler

        Process exitHandler​(Handler<Integer> handler)
        Set the handler to be called when the process exits, the handler will be called with the process status code value.
        Parameters:
        handler - the handler
        Returns:
        a reference to this, so the API can be used fluently
      • pid

        Integer pid()
        Returns:
        the process PID or null if the process is not running
      • stdin

        StreamOutput stdin()
        Returns:
        the process stdin stream
      • stdout

        StreamInput stdout()
        Returns:
        the process stdout stream
      • stderr

        StreamInput stderr()
        Returns:
        the process stderr stream
      • kill

        default void kill()
        Terminates the process in a graceful manner.

        On a POSIX OS, it sends the SIGTERM.

      • kill

        void kill​(boolean force)
        Terminates the process.

        If force is false, the process will be terminated gracefully (i.e. its shutdown logic will be allowed to execute), assuming the OS supports such behavior. Note that the process may not actually terminate, as its cleanup logic may fail or it may choose to ignore the termination request. If a guarantee of termination is required, call this method with force equal to true instead.

        If force is true, the process is guaranteed to terminate, but whether it is terminated gracefully or not is OS-dependent. Note that it may take the OS a moment to terminate the process, so isRunning() may return true for a brief period after calling this method.

        On a POSIX OS, it sends the SIGTERM or SIGKILL signals.

        Parameters:
        force - if true is passed, the process will be forcibly killed
      • isRunning

        boolean isRunning()
        Tests whether or not the process is still running or has exited.