I am trying to help a user at AskUbuntu with the following question,
Exiting the terminal vs Closing the terminal
Context:-
I am running a process in bash with
&
appended i.e in background mode. The process has awhile(1)
i.e it will run forever. My bash is parent and my process becomes the child. I want to learn how Kernel handles the child when parent is terminated.Observations:-
- If I exit the terminal (using
exit
command from the terminal),/lib/systemd/systemd --user
becomes the parent process of the child- If I kill the terminal process (using
kill
) from another terminal, same result as above- If I close the terminal using cross icon, child process gets terminated too
Question:-
How is closing different from killing/exiting?
I have written an answer, but feel that I do not really understand what is happening, and I think that several of you who help here at Unix & Linux know better than I and can explain what is happening.
So please help us understand, by chipping in and write an answer (replacing my attempt at AskUbuntu).