systemd service & tty: Rocky vs Ubuntu (I don't understand what's going on)
0
votes
0
answers
33
views
I cannot determine the root cause of the different behavior when running the following onestot.service on Rocky 9 (where it works) and Ubuntu 24 (where it does not work).
What I need to do is capture the output of **btop** for a few seconds and store it in a file (**btop** does not have a batch mode or similar functionality).
This is the setup needed to reproduce the different behaviour.
cat > /etc/systemd/system/oneshot.service /var/lib/oneshot/take-screenshot /var/lib/oneshot/btop-screenshot /var/lib/oneshot/btop-screenshot.log
EOF
chmod +x /var/lib/oneshot/btop-screenshot
systemctl daemon-reload
systemctl restart oneshot.service
In Rocky, both **btop-screenshot.dbg** and **btop-screenshot.log** will contain the graphical output of **btop** (a lot of color escape sequences mixed with text) while in Ubuntu, they will contain no **btop** output at all.
Prepending **strace** to **btop** reveals where **btop** hangs indefinitely in Ubuntu:
script -c 'timeout 5 strace btop' /var/lib/oneshot/...
Ubuntu (**btop** hangs indefinitely at this **ioctl** call - return code is **?**):
ioctl(0, TCSETS, {c_iflag=BRKINT|IGNPAR|ICRNL|IXON, c_oflag=NL0|CR0|XTABS|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD|CLOCAL, c_lflag=ISIG|ICANON|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
Rocky (**btop** continues running after the same **ioctl** call - return code is **0**):
ioctl(0, TCSETS, {c_iflag=BRKINT|IGNPAR|ICRNL|IXON, c_oflag=NL0|CR0|XTABS|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD|CLOCAL, c_lflag=ISIG|ICANON|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
This is where I got stuck since I have no idea what that **ioctl** call means.
I have tried to play with both systemd's **StandardOutput** and **TTYPath** options without success.
If you have any clue about why the output of **btop** cannot be captured using a system service in Ubuntu, please let me know.
I appreciate your help.
**NOTE**: running **take-screenshot** directly in a terminal without involving systemd works in both OSes.
Asked by mguglielmi
(1 rep)
Jul 2, 2025, 09:47 AM
Last activity: Jul 2, 2025, 10:26 AM
Last activity: Jul 2, 2025, 10:26 AM