[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: What is agetty, and why can't it be stopped?



On Thu, Jun 06, 2019 at 09:22:02AM +0200, tomas@tuxteam.de wrote:
> Getty stayed the parent of that whole session "process
> tree", which at the end of the session folded nicely back.
> On termination of getty's child, getty itself terminated.

I'm pretty sure getty has always used exec() to replace itself with
login(1) or a login(1) equivalent.  There's no reason for it to sit
around holding memory.

> I don't know where /etc/inittab is under that newfangled
> init system, but I'm sure others will chime in.

There isn't one under systemd.

This might be a starting point:

========================================================================
wooledg:~$ grep -ri serial /lib/systemd/system
/lib/systemd/system/getty@.service:Documentation=http://0pointer.de/blog/projects/serial-console.html
/lib/systemd/system/getty@.service:# that serial gettys are covered by serial-getty@.service, not this
/lib/systemd/system/getty.target:Documentation=http://0pointer.de/blog/projects/serial-console.html
/lib/systemd/system/serial-getty@.service:Description=Serial Getty on %I
/lib/systemd/system/serial-getty@.service:Documentation=http://0pointer.de/blog/projects/serial-console.html
/lib/systemd/system/getty-pre.target:Documentation=http://0pointer.de/blog/projects/serial-console.html
/lib/systemd/system/wacom-inputattach@.service:Description=inputattach for Wacom ISDv4-compatible serial devices
/lib/systemd/system/wacom-inputattach@.service:ExecStart=/usr/bin/isdv4-serial-inputattach /dev/%I

wooledg:~$ cat /lib/systemd/system/serial-getty@.service
#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Serial Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
BindsTo=dev-%i.device
After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes

# IgnoreOnIsolate causes issues with sulogin, if someone isolates
# rescue.target or starts rescue.service from multi-user.target or
# graphical.target.
Conflicts=rescue.service
Before=rescue.service

[Service]
# The '-o' option value tells agetty to replace 'login' arguments with an
# option to preserve environment (-p), followed by '--' for safety, and then
# the entered username.
ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,38400,9600 %I $TERM
Type=idle
Restart=always
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes

[Install]
WantedBy=getty.target
========================================================================

Now, I'm definitely no systemd guru.  I do know that the @ sign in the
service name is magical -- it acts like a wildcard of some kind, meaning
this is a service that can have a bunch of instances running.

It points to <http://0pointer.de/blog/projects/serial-console.html> which
looks like it's definitely worth reading.  You'll want to digest that
before doing anything else.


Reply to: