3

On Lubuntu 18.04, if I click the desktop menu, and lxterminal in it, and run the the following in the terminal emulator window, I will get

$ pstree -a -p   -s $$
systemd,1 --system --deserialize 19
  └─lightdm,661
      └─lightdm,862 --session-child 12 19
          └─lxsession,944 -s Lubuntu -e LXDE
              └─lxpanel,1087 --profile Lubuntu
                  └─lxterminal,23017
                      └─bash,23020
                          └─pstree,26853 -a -p -s 23020

If I hit Alt+F2, and run lxterminal and run the following in the terminal emulator window, I will get

$ pstree -a -p   -s $$
systemd,1 --system --deserialize 19
  └─lxterminal,1480
      └─bash,27000
          └─pstree,27013 -a -p -s 27000

How does the second make lxterminal run as a child of systemd? Is it done by orphaning the lxterminal process and reparenting it to systemd?

What were the original parent and grandparent of the lxterminal process?

My question is actually more general: how does Alt+F2 run any command as child of the init process?

Where is the relevant source code?


My suspicion:

when I hit alt_F2, I guess it is equivalent to click the menu panel of the desktop environment and then select "Run". I guess what happens in the equivalent is

The lxpanel process forks a process to show the Run window for asking what command to run, which then exits after forking a second process to run the specified command. That reparents the process executing the specified command to the init process. (Unlike creating a daemon process, the process executing the specified command doesn't start a new process session.)

Since lxpanel is in the process session led by lxession,944, and has no controlling terminal, the process running the specified command is in the same session and also has no controlling terminal. There seems to be no worry about being sent SIGHUP, if not reparenting the process executing the specified command to the init process, by terminating the middle process early.

So what is the purpose of reparenting the process executing the specified command to the init process, by terminating the middle process early?

Pro Backup
  • 4,924
Tim
  • 101,790
  • 1
    Might help if you provide systemd version. – 炸鱼薯条德里克 Dec 21 '18 at 05:23
  • what "version" did I provide? – Tim Dec 21 '18 at 12:55
  • +1. Odd. I must have read the code wrong, I thought it calls into libfm, but then the libfm function deliberately avoids this. See the 2015 commit https://github.com/lxde/libfm/commit/fad5a9a3e3a3148d1275b7ba048614aa4c7c0414#diff-0d8e4bab07d1bfe6e6d872473ce9d234 The libfm commit description is very short, but you can understand the libfm commit by reading the bug report that lead to a similar change in Ubuntu Unity: https://bugs.launchpad.net/ubuntu/+source/update-manager/+bug/1020115 . – sourcejedi Dec 22 '18 at 20:22
  • The middle process exiting is pretty natural, since the only purpose of it is showing the input window, after creating the command process, it's not needed anymore. I'm just wondering, why the command process is reparented to init, not systemd user instance, it should be the nearest reaper process. This behaviour might have been changed with systemd version. – 炸鱼薯条德里克 Jan 12 '19 at 11:57

0 Answers0