java执行logcat重定向后,怎么停止logcat运行?

代码如下: String tmpCmd = "adb logcat -v threadtime '*:V' > E:\\qq.log"; try { Process proc = Runtime.getRuntime().exec(new String[] { "cmd.exe", "/c", tmpCmd }); proc.destroy(); } catch (IOException e) { e.printStackTrace(); }在执行proc.destroy()后,adb logcat命令还在执行。有什么方法可以让命令停止?

好像没什么办法,以下是Process类关于进程杀死的描述The subprocess is not killed when there are no more references to the Process object, but rather the subprocess continues executing asynchronously。也就是说,Process.destroy可能可以杀死子进程,也可能杀不死子进程。其中的相关性,要看destory的实现才知道。通过伪终端的方法,可以发送Ctrl+c进而发送SIGINT中断来杀死进程。
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-04-03
那复杂一点,再用Runtime运行TaskLisk 找到adb的PID,然后再用TaskKill 来终止之
相似回答