Java Code Examples for java.lang.Process#destroyForcibly()

The following examples show how to use java.lang.Process#destroyForcibly() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MXBeanWeirdParamTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example 2
Source File: MXBeanWeirdParamTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example 3
Source File: MXBeanWeirdParamTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example 4
Source File: MXBeanWeirdParamTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example 5
Source File: MXBeanWeirdParamTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example 6
Source File: MXBeanWeirdParamTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }
 
Example 7
Source File: MXBeanWeirdParamTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Runs MXBeanWeirdParamTest$ClientSide with the passed options and redirects
 * subprocess standard I/O to the current (parent) process. This provides a
 * trace of what happens in the subprocess while it is runnning (and before
 * it terminates).
 *
 * @param serviceUrlStr string representing the JMX service Url to connect to.
 */
private int runClientSide(String serviceUrlStr) throws Exception {

    // Building command-line
    List<String> opts = buildCommandLine();
    opts.add(serviceUrlStr);

    // Launch separate JVM subprocess
    int exitCode = 0;
    String[] optsArray = opts.toArray(new String[0]);
    ProcessBuilder pb = new ProcessBuilder(optsArray);
    Process p = ProcessTools.startProcess("MXBeanWeirdParamTest$ClientSide", pb);

    // Handling end of subprocess
    try {
        exitCode = p.waitFor();
        if (exitCode != 0) {
            System.out.println(
                "Subprocess unexpected exit value of [" + exitCode +
                "]. Expected 0.\n");
        }
    } catch (InterruptedException e) {
        System.out.println("Parent process interrupted with exception : \n " + e + " :" );

        // Parent thread unknown state, killing subprocess.
        p.destroyForcibly();

        throw new RuntimeException(
            "Parent process interrupted with exception : \n " + e + " :" );
    } finally {
        return exitCode;
    }

 }