I am executing a shell pipeline from a java program - it will be something like
ProcessBuilder builder = new ProcessBuilder(
"sh", "-c", "program1 | program2 | program3");
builder.start();
In some cases, this device may be discontinued. but
process.destroy();
Destroy the sh command. The commands in pipline will be orphaned and accepted by the init process.
Is there a way to easily terminate all these child processes - or execute a pipeline, as shown above, in such a way as to simplify their completion. Changing program 1/2/3 is not possible. Portability outside of Linux is not a problem.
source
share