Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

relation between init and bash terminal process

Tags:

linux

memory

Whenever we open a terminal, kernel creates a process(bash-terminal using fork+exec) and it's parent process is "init". But this "mate-terminal" becomes parent and creates another process "terminal" which is visualised by user.

Just wanted to know what sort of file descriptors,memory etc are shared between the "init"(pid=1,ppid=0), "mate-terminal"(pid=200 and ppid=1) and "terminal"(pid=201 and ppid=200).

I know about the process stack and which segments are shared but unable to clearly visualise in this practical scenario.

Please help me in understanding the memory sematics of the process..

Any help is welcome..

like image 513
Santosh Sahu Avatar asked Sep 20 '26 23:09

Santosh Sahu


1 Answers

Nothing is shared between init and its terminal children, nor between the first terminal and its terminal child.

This is because, although fork() will make both processes (father and child) to share some objects, exec() family functions completely replaces the current process image with a new process image.

This means that all references to previous objects, such as shared file descriptors from the father, are forgotten.

like image 110
user2492779 Avatar answered Sep 24 '26 01:09

user2492779



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!