I have a script that launches another script in the background, and then terminates it. I was expecting the child script to be gone, but in the end it still manages to print some output. Here is the 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 is supposed to run two.sh in the background, which in turn runs three.sh but not in the background! The output is get is:
this is one
this is two
this is three
this was one
this was three
Shouldn't "this was three" not appear in the output since three.sh was not ran in the background and two.sh was terminated by one.sh? Could you also point me towards any documentation that describes how processes behave when (not) in background and what happens when they are terminated?
Thank you very much for all your help!