I am using Linux. When i opened gedit program in gnome-terminal by gedit command it has opened the graphical gedit text editor. then the gedit has PPID bash

    ashokkrishna@ashokkrishna-Lenovo-B560:~$ ps -eaf | grep gedit
    ashokkr+  1682   820  3 04:09 pts/6    00:00:00 gedit
    ashokkr+  1695  1568  0 04:09 pts/9    00:00:00 grep --color=auto gedit

here 820 is the PID of bash

ashokkr+   820 32505  0 03:32 pts/6    00:00:00 bash

but when i opened same gedit by double clicking the gedit icon.

ashokkrishna@ashokkrishna-Lenovo-B560:~$ ps -eaf | grep gedit
ashokkr+  1855  1982 14 04:16 ?        00:00:00 /usr/bin/gedit

I got 1982 PPID which is init

1982 ?        00:00:00 init

Now my question is why the parent process is different in both cases?
what is the exact process initiates user processes?

  • i am using ubuntu 14.04 – ashok Dec 6 '14 at 23:30

What you're seeing should not surprise you. You've started gedit two different ways, via two different parents, so of course the PPID — parent process ID — is different in the two cases.

The first is a child of Bash, because you started it from a Bash command line.

The second child's initial process will be your OS's GUI system, but because it's being forked into the background, it gets orphaned, so init adopts it. This is the standard way of handling orphaned processes on a Unix/Linux system.

The shell (Bash) simply isn't involved in the second case. Bash is a child of Gnome Terminal, which will be started by some core component of the system. I see upstart as the parent on my Ubuntu 14.10 box, but that will vary on different Linux and Unix systems. When the terminal closes, so will Bash, as will any programs started by Bash that haven't been let go into the background somehow.

Ultimately, all processes are started by the kernel, usually via some wrapper around the execve(2) system call. But, you aren't going to see the kernel as a parent process here; the kernel acts on behalf of some user process, so that process gets recorded as the parent.

The reason init(8) is not PID 1 is covered in another answer here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.