I have a bash script script1
:
#! /bin/bash
evince
and another script script2
#! /bin/bash
evince &
When I run
./script2
the bash process exits immediately after putting evince
into background, leaving the evince
process continue running.
When I run
./script1 &
the bash process waits for evince
to finish running.
If I kill
the bash process, the bash process exits and also terminates the evince
process.
I was wondering why the termination of the bash process doesn't affect the evince
process in the second script, but does in the first script?
Could you explain in terms of system calls such as fork(), exit()
and wait()
?
Thanks.
This is related to Why can this script running in the background survive `kill` and termination of the invoking shell?, but here I want to learn the basic general case.