I use Runtime.getRuntime().exec to execute command tail -f filename | grep str which is based on OS pipe.I managed to achieve my business logic.But still there is a problem I must solve:
when using pipe,the Process will for another process for tail command:
$ ps -ef | grep test.log
admin 6953 32721 0 16:32 ? 00:00:00 /bin/sh -c tail -f /home/admin/test.log | unbuffer -p grep ‘1444379575648’
admin 6957 6953 0 16:32 ? 00:00:00 tail -f /home/admin/test.log
Process.destroy() method destroys itself(pid:6953) only.How can I destroy its subprocess(pid:6957) in my Java program?