0

The man page for scope says:

Unlike service units, scope units manage externally created processes, and do not fork off processes on its own.

On my RHEL server, I can see that gdm belongs to the gdm service. So does its child, gdm-simple-slave. gdm-simple-slave has created gdm-session-worker, but this process belongs to a scope, not the gdm service.

In light of this, what does "externally created process" mean, and what is the difference between a service and a scope?

For those readers who prefer code:

# systemctl status gdm
gdm.service - GNOME Display Manager
   Loaded: loaded (/usr/lib/systemd/system/gdm.service; enabled)
   Active: active (running) since Sun 2018-03-04 16:27:45 EST; 1 day 3h ago
  Process: 1330 ExecStartPost=/bin/bash -c TERM=linux /usr/bin/clear > /dev/tty1 (code=exited, status=0/SUCCESS)
 Main PID: 1307 (gdm)
   CGroup: /system.slice/gdm.service
           ├─1307 /usr/sbin/gdm
           ├─1331 /usr/libexec/gdm-simple-slave --display-i...
           └─1364 /usr/bin/Xorg :0 -background none -verbos...
# ps -ef|grep 1331
root      1331  1307  0 Mar04 ?    00:00:00 /usr/libexec/gdm-simple-slave...
root      2032  1331  0 Mar04 ?    00:00:00 gdm-session-worker ...
# systemctl status 2032
session-38.scope - Session 38 of user root
   Loaded: loaded (/run/systemd/system/session-38.scope; static)
  Drop-In: /run/systemd/system/session-38.scope.d
           └─90-After-systemd-logind\x2eservice.conf, 90-After-systemd-user-sessions\x2eservice.conf, 90-Description.conf, 90-SendSIGHUP.conf, 90-Slice.conf
   Active: active (running) since Sun 2018-03-04 21:12:08 EST; 22h ago
0

An externally created process is a process that was spawned by a process other than the systemd daemon running as PID 1.

For both a scope and a service, systemd will create the cgroups to allow you to manage the processes inside it as a whole. (For example, you can use systemctl stop to stop a scope and kill all processes inside it.)

But with a service, systemd has the command-line to run and will run it in that environment.

With gdm-session-worker, for instance, that is not really possible, since it's supposed to be spawn by gdm-simple-slave... So in order to still keep a separate session for each gdm-session-worker, gdm will still communicate with systemd to ask it to create a new scope and then create that gdm-session-worker in that new scope.

I hope this answers your question... You have already found the systemd scope man page. If you want a more technical deep dive onto the API you might want to look into the New Control Group Interfaces, though perhaps an easier way to try it is using the systemd-run --scope command.

|improve this answer|||||
  • Thanks Filipe. I am sorry but I am still missing something. gdm-simple-slave is created by the gdm process, not by systemd. According to your definition, it should then be an external process. Why is it a member of the gdm service, then? On the other hand, the child of gdm-simple-slave is considered external. So, while I now understand the purpose of services and scopes, I continue to be confused. – berndbausch Mar 11 '18 at 8:11
  • @berndbausch Sorry, I meant gdm-session-worker is created by gdm-simple-slave (not systemd) so gdm-session-worker is an external process. Then gdm-simple-slave asks systemd to add it to the scope of the user session. While gdm-simple-slave is not itself started by systemd, it belongs to a service that was started when systemd spawned a process (gdm.) I guess the difference is how transitions are made, gdm-session-worker process was first created and then moved to a scope. Starting a service will always spawn a process from it. – filbranden Mar 13 '18 at 16:55

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.