I have a script that runs another script in the background and then terminates it. I expected the child script to disappear, but in the end, it still manages to print some result. Here is an example:
in script one.sh:
echo "this is one" ./two.sh & sleep 1 pid=$! kill $pid echo "this was one"
in script two.sh:
echo "this is two" ./three.sh echo "this was two"
in script three.sh:
echo "this is three" sleep 5 echo "this was three"
I ran. /one.sh, which should run two.sh in the background, which in turn starts three.sh, but not in the background! Output: get:
this is one this is two this is three this was one this was three
Should "this was three" not be displayed in the output file, since three.sh did not start in the background, and two.sh was interrupted by one.sh? Could you also point me to any documentation that describes how processes behave when (not) in the background and what happens when they end?
Many thanks for your help!
source share