Shell script: the child process do not terminate in linux

Solution 1:

If you are using bash, you should use the wait command, rather than an elaborate polling loop. I don't know about other shells (sh, zsh, and so on), but I assume most/all of them also have wait, or an equivalent to it.