Java Kill Process killProcessWithArgs(List args)

Here you can find the source of killProcessWithArgs(List args)

Description

kill Process With Args

License

Open Source License

Parameter

Parameter Description
args a parameter

Declaration

private static void killProcessWithArgs(List<String> args) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**//from w  ww  . ja va2  s .  c om
     *
     * @param args
     */
    private static void killProcessWithArgs(List<String> args) {
        List<String> list = new ArrayList<>();
        list.add("/usr/bin/pkill");
        list.addAll(args);
        try {
            Process child = new ProcessBuilder(list.toArray(new String[list.size()])).start();
            child.waitFor();
        } catch (InterruptedException | IOException e) {
            throw new RuntimeException("Can't kill process: " + e.getMessage());
        }
    }
}

Related

  1. killProcess(String name)
  2. killProcess(String processName)
  3. killProcess(String processName)
  4. killProcessesTree(String rootNamePart)
  5. killProcessNix(String pid)