1
0
mirror of https://github.com/systemd/systemd synced 2025-11-18 08:14:46 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Allison Karlitskaya
516df12af9 udevadm: flush output after each monitor event
If you're using `udevadm monitor` from a script, without a tty, then
libc defaults to being fully-buffered, and won't flush stdout after
newlines.  This is fine for tools that dump a bunch of data and then
exit immediately.  It's a problem for tools like `udevadm monitor` which
have long pauses: the buffered data can get stuck in the buffer for an
unbounded amount of time.

In the Cockpit project we've been working around this for some time with
`stdbuf` which is a `LD_PRELOAD` hack to change the libc buffering
behaviour, but we'd like to stop doing that.

Let's make sure we flush the buffer after each event.
2025-10-28 17:51:19 +01:00
Yu Watanabe
6454fde83e TEST-07-PID1: wait for systemd-resolved being stopped
As 'systemctl stop' is called with --no-block, previously systemd-resolved
might not be stopped when 'resolvectl' is called, and the DBus connection
might be closed during the call:
```
TEST-07-PID1.sh[5643]: + systemctl stop --no-block systemd-resolved.service
TEST-07-PID1.sh[5643]: + resolvectl
TEST-07-PID1.sh[5732]: Failed to get global data: Remote peer disconnected
```

Follow-up for 8eefd0f4debc0bcfeea89dd39c43e3318f3f7ae7.
Fixes https://github.com/systemd/systemd/pull/39388#issuecomment-3439277442.
2025-10-28 13:26:15 +00:00
2 changed files with 5 additions and 0 deletions

View File

@ -55,6 +55,8 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device,
printf("\n");
}
fflush(stdout);
return 0;
}

View File

@ -35,6 +35,9 @@ for i in {1..5}; do
echo "Start #$i"
systemctl stop --no-block systemd-resolved.service
# Wait for systemd-resolved in ExecStart= being stopped.
# shellcheck disable=SC2016
timeout 10 bash -c 'until [[ "$(systemctl show --property=MainPID --value systemd-resolved.service)" == 0 ]]; do sleep 0.1; done'
if ! resolvectl; then
journalctl -o short-monotonic --no-hostname --no-pager -u systemd-resolved.service -n 15
exit 1