why is the ppid is 1 for a user process?
I have an application which runs few processes.
"ps" output of one of the processes shows the PPID of a process is 1. what it exactly it means? |
The "init" process always takes PID 1, when a process dies, it's child processes are inherited by him. Generally, init only starts system processes
A user process having 1 as PPID means probably that this process was created as a user-space one, and after that, it's father died. |
Moin,
you can yourself create such processes using "nohup program &". They will run at the background and don't terminate, when you exit the shell. Jan |
One of the fundamental design-points of Linux or Unix is that many things are done by "spawning child processes" to do things, then waiting for them to finish and examining the return-code they provide. For this reason, when a process dies, it enters a "zombie" state that specifically exists so that the parent-process can "reap" the now-dead child and, in so doing, collect its status information.
"But what if the parent dies first?" Generally, but not always, the death of a parent causes the death of all of its direct or indirect children. But in any case, when any process dies, some "parent process" must "reap" it. If there is no "true" parent-process available, "process #1: init" gets to serve as the Grim Reaper, among its various other duties. "init" is a very special process: it is created by the system during startup, and it never dies. (It is not allowed to die... a "kernel panic" will occur if it ever does.) |
when a process is created it's typically from a user's shell, the shell is the session leader.
and the parent. when you logout the shell all the kids die too. they get a signal from the parent. sometimes you want a process to be independent of the parent, like a daemon, so it doesn't die when you log out. so typically if you want this behaviour the program calls fork followed by setsid becoming a session leader and getting the PPID of 1 the 'init' process which is the ultimate parent of all. e.g. gvim does this. |
venkat_k:
Just to clarify - jan61's response is probably closest to what you were actually looking for: Quote:
'Hope that helps .. PSM |
All times are GMT -5. The time now is 04:01 AM. |