Suppose there are several Java projects whose task is to run other Java processes. The procedure is similar to the following:
String[] command = { "/bin/sh", "-c", "some.sh" + " &"};
Process pro = Runtime.getRuntime().exec(command);
//rest
This first option works because &, and this other one does not work:
String[] command = { "/bin/sh", "some.sh"};
Process pro = Runtime.getRuntime().exec(command);
//rest
Q: What is the meaning of "this does not work"? A: Both options start the process, but in the second case, the child process stops working after a few seconds, however, if I check the running processes ( ps aux | grep some.sh), it is (but does nothing). The first option works fine, it starts the process, and the child performs his task.
I donβt understand why, when I start a child process without a background, it appears as active in the process list ps, but does nothing.