2

I've noticed, that all mate-terminal instances I start, be it inside a mate-terminal or via a link button, have the same PID.

For example, I got something like

 $ wmctrl -lp
 <omitted lines that don't matter>
 0x03c0001f  1 7411   <hostname> Terminal
 0x03c06b9f  1 7411   <hostname> Terminal
 0x03c07349  1 7411   <hostname> Terminal
 0x03c073f4  1 7411   <hostname> Terminal
 0x03c0749f  1 7411   <hostname> Terminal
 0x03c0754c  1 7411   <hostname> Terminal
 0x03c075f9  1 7411   <hostname> Terminal
 0x03c076a6  1 7411   <hostname> Terminal
 0x0340000b  1 <pid1> <hostname> xeyes
 0x0460000b  1 <pid2> <hostname> xeyes

which clearly shows that there are multiple Terminal windows, all with the same PID. As stated above, it didn't matter, whether or not the process was started inside a terminal or by clicking a menu bar link. Neither did it matter, whether or not I started the process in the background inside the terminal.

What is the applied rule here, or "why is this so"?
My understanding used to be that every command I start in a shell would obtain a unique PID.

Isn't it kind of impractical to have multiple terminals with the same PID?
I can't kill them individually by PID anymore.

Edit: Kernel version: 3.16.0-4-amd64

3

All the instances of Mate Terminal have the same PID because they are in fact a single process which happens to display multiple windows. Mate Terminal runs in a single process because that's the way the application is designed. When you run the command mate-terminal, it contacts the existing process and sends it an instruction to open a new window.

As of Mate Terminal 1.8.1, you can run mate-terminal --disable-factory to open a new window in a new process. Beware that this option has been removed from the Gnome version in 3.10; I don't know whether the Mate developers have decided to merge that change. See Run true multiple process instances of gnome-terminal for a similar question regarding Gnome-terminal.

  • But what about xeyes and mate-terminals run from, say a menu bar link also creating processes under the same PID? In that case, the mate-terminals are not called from the first one. Also, xeyes can't call any other xeyes processes, can it (?) – polynomial_donut Aug 31 '15 at 6:14
  • 1
    When you run mate-terminal, it contacts the existing process, no matter where you ran it from: the second mate-terminal process is not the one that displays the window, it just sends commands to the existing one and waits for the first one to tell it that the window was closed. If you run xeyes twice, you get two different processes. You can see it in the window IDs: they encode the client connection to the X server, and there's usually one per process. All the Mate Terminal windows in your wmctrl output come from connection 0x03c. The xeyes windows come from connections 0x034 and 0x046. – Gilles Aug 31 '15 at 7:32
  • Oh yeah, you're right about xeyes. Somehow I didn't catch that properly, was probably too tired x_X Can you maybe elaborate on "connections"? If you don't mind... – polynomial_donut Sep 2 '15 at 22:13
  • 2
    @polynomial_donut Technically the X server identifies clients that are connected through a socket. It's possible for the same process to open multiple connections (i.e. open multiple sockets) to connect to the same X server. And conversely it's possible for multiple processes to use the same connection, if the original process that opened the socket forked. But in practice one connection almost always corresponds to one process. – Gilles Sep 2 '15 at 22:20
0

Trying to really answer the question "why":

If every window were handled by a different process, you wouldn't be able to drag-n-drop a tab from one window to another, or drop on the desktop to create a new window for that.

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.