Java ProcessBuilder process.destroy() not killing child processes in winXP

前端 未结 2 1290
死守一世寂寞
死守一世寂寞 2020-12-20 14:09

I have a java app that uses ProcessBuilder to prepare an operating system command and gives me a Process object. (The actual os command is rsync ov

2条回答
  •  清歌不尽
    2020-12-20 14:48

    I'm not sure what Process.destroy() does under the covers (sends a signal or similar?).

    What you may find works better is to invoke your ssh/rsync within a shell script, and have that return a process id on stdout, and then when you want to kill the process, perform a /bin/kill with that process id. A little messy, but perhaps more reliable.

    Note you can /bin/kill with SIGTERM, and SIGKILL if it's particularly stubborn.

提交回复
热议问题