Repository navigation
Closed
Description
systemd version the issue has been seen with
255.6-1-arch, 255.4
Used distribution
Arch Linux, NixOS unstable
Linux kernel version used
6.9.1-arch1-1, 6.9.0-rc6
CPU architectures issue was seen on
x86_64
Component
systemd-run
Expected behaviour you didn't see
Show outputs from ExecStartPre command, then from ExecStart command, then from ExecStopPost, and finally exit.
Unexpected behaviour you saw
Show outputs from ExecStartPre command, then blocks indefinitely without showing outputs of the main command. It does not exit even after the main command exits or hitting Ctrl-] several times.
Steps to reproduce the problem
$ systemd-run --user --pty --collect --service-type=exec --property=ExecStartPre='/bin/sh -c "echo pre"' -- echo work
Running as unit: run-u4179.service; invocation ID: efce5f29353341febf359cefd4a00faa
Press ^] three times within 1s to disconnect TTY.
pre
<blocks indefinitely, until hitting Ctrl-C. Note that Ctrl-] does not work.>- When blocked, hitting
Ctrl-]3 times within 1s also does nothing. - When blocked, the main service
echo workis already executed and exited. It can be observed by usingbash -c 'echo work; sleep 5'as main command and checkinghtop. - It must be both
ExecStartPreand the main command printing something into either stdout or stderr. If one of them prints nothing (eg.trueorsleep), it does not trigger the issue. ExecStopPostalso reproduces. This is actually the original issue I've entered. Because I want to add some cleanup code after the transient service command exits, even when it's stopped abnormally.- Use
--pipeinstead of--ptyworks as expected. But that is not suitable when the command need an actual PTY.
Additional program output to the terminal or log subsystem illustrating the issue
$ journalctl --user -u run-u4179.service --since=-1h
May 18 20:01:52 invar systemd[1936]: Starting /run/current-system/sw/bin/echo work...
May 18 20:01:52 invar systemd[1936]: Started /run/current-system/sw/bin/echo work.
Backtrace of `systemd-run`:
#0 0x00007f26ed71d1c7 in epoll_wait () from /nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib/libc.so.6
#1 0x00007f26edad95d5 in sd_event_wait ()
from /nix/store/7kq9hvrhcy8g1v0jd07nr54279asg9vc-systemd-255.4/lib/systemd/libsystemd-shared-255.so
#2 0x00007f26edadb95b in sd_event_run ()
from /nix/store/7kq9hvrhcy8g1v0jd07nr54279asg9vc-systemd-255.4/lib/systemd/libsystemd-shared-255.so
#3 0x00007f26edadbb4f in sd_event_loop ()
from /nix/store/7kq9hvrhcy8g1v0jd07nr54279asg9vc-systemd-255.4/lib/systemd/libsystemd-shared-255.so
#4 0x000055c1d823fc23 in start_transient_service ()
#5 0x000055c1d823ad6a in main ()
Activity
run: pass the pty slave fd to transient service
Workaround a systemd-run bug and add `--pipe`
run: pass the pty slave fd to transient service
run: do not pass the pty slave fd to transient service in a machine
run: do not pass the pty slave fd to transient service in a machine
run: do not pass the pty slave fd to transient service in a machine
run: pass the pty slave fd to transient service
run: pass the pty slave fd to transient service
run: do not pass the pty slave fd to transient service in a machine