Skip to content

Commit b4bf900

Browse files
committed
getty: Pass tty to use by agetty via stdin
If the tty arg is set to "-", agetty uses the stdin fd as the tty. Let's pass the tty this way so that we keep an fd open to the tty at all times. If all fd's to a tty are closed, the kernel might reset the tty which we want to avoid.
1 parent 8389fd1 commit b4bf900

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

units/console-getty.service.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ ConditionPathExists=/dev/console
2323
# The '-o' option value tells agetty to replace 'login' arguments with an
2424
# option to preserve environment (-p), followed by '--' for safety, and then
2525
# the entered username.
26-
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear --keep-baud console 115200,38400,9600 $TERM
26+
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear --keep-baud - 115200,38400,9600 $TERM
2727
Type=idle
2828
Restart=always
2929
UtmpIdentifier=cons
30+
StandardInput=tty
31+
StandardOutput=tty
3032
TTYPath=/dev/console
3133
TTYReset=yes
3234
TTYVHangup=yes

units/container-getty@.service.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ Before=rescue.service
2828
# The '-o' option value tells agetty to replace 'login' arguments with an
2929
# option to preserve environment (-p), followed by '--' for safety, and then
3030
# the entered username.
31-
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear --keep-baud pts/%I 115200,38400,9600 $TERM
31+
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear --keep-baud - 115200,38400,9600 $TERM
3232
Type=idle
3333
Restart=always
3434
RestartSec=0
3535
UtmpIdentifier=pts/%I
36+
StandardInput=tty
37+
StandardOutput=tty
3638
TTYPath=/dev/pts/%I
3739
TTYReset=yes
3840
TTYVHangup=yes

units/getty@.service.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ ConditionPathExists=/dev/tty0
3838
# The '-o' option value tells agetty to replace 'login' arguments with an
3939
# option to preserve environment (-p), followed by '--' for safety, and then
4040
# the entered username.
41-
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear %I $TERM
41+
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear - $TERM
4242
Type=idle
4343
Restart=always
4444
RestartSec=0
4545
UtmpIdentifier=%I
46+
StandardInput=tty
47+
StandardOutput=tty
4648
TTYPath=/dev/%I
4749
TTYReset=yes
4850
TTYVHangup=yes

units/serial-getty@.service.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ Before=rescue.service
3333
# The '-o' option value tells agetty to replace 'login' arguments with an
3434
# option to preserve environment (-p), followed by '--' for safety, and then
3535
# the entered username.
36-
ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,57600,38400,9600 %I $TERM
36+
ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,57600,38400,9600 - $TERM
3737
Type=idle
3838
Restart=always
3939
UtmpIdentifier=%I
40+
StandardInput=tty
41+
StandardOutput=tty
4042
TTYPath=/dev/%I
4143
TTYReset=yes
4244
TTYVHangup=yes

0 commit comments

Comments
 (0)