user3753682
user3753682

Reputation: 187

Does shell script invoked by java get killed when the java process is killed?

I have a few doubts on process termination. My use case is such that

  1. Java process invokes a shell script process through Process Builder
  2. The shell script invokes a new process x

Does process.destroy() in java also kill the process x along with shell script?

What happens when the Java process is killed while x is running? Is both shell script process and process x killed?

Upvotes: 2

Views: 382

Answers (1)

Davide Lorenzo MARINO
Davide Lorenzo MARINO

Reputation: 26926

There is no tie between a child process and its parent.

Both process can know each other ids, but there is not a hard link between them.

Generally what happens to children of a process when it is killed is platform dependent, so there is not guarantee that when you kill a process created from java also the children of that process will be killed too. Additionally you program can have different behaviour on different operating systems.

Upvotes: 3

Related Questions