systemd-run -p PrivatePIDs=yes --remain-after-exit --unit TEST-07-PID1-private-pid sleep infinity
# Wait for ExecMainPID to be correctly populated as there might be a race between spawning service
# and actual exec child process
- timeout 10s bash -xec 'until [[ "$(cat /proc/$(systemctl show TEST-07-PID1-private-pid.service -p ExecMainPID --value)/comm)" == sleep ]]; do sleep .5; done'
+ # Note, Alpine/postmarketOS build coreutils with --enable-single-binary=symlinks. In that case, coreutils
+ # calls prctl(PR_SET_NAME, argv[0]), hence the comm will be the path to the symlink. If the sleep file is
+ # a dedicated binary (like most other distributions do), the comm will be the filename, i.e. "sleep". So,
+ # here we need to cut the directory part.
+ timeout 10s bash -xec 'until [[ "$(cat /proc/$(systemctl show TEST-07-PID1-private-pid.service -p ExecMainPID --value)/comm | sed -e "s|.*/||")" == sleep ]]; do sleep .5; done'
pid=$(systemctl show TEST-07-PID1-private-pid.service -p ExecMainPID --value)
kill -9 "$pid"
timeout 10s bash -xec 'while [[ "$(systemctl show -P SubState TEST-07-PID1-private-pid.service)" != "failed" ]]; do sleep .5; done'
systemctl stop testsleep.service
rm -f /run/udev/udev.conf.d/timeout.conf
rm -f /run/udev/rules.d/99-testsuite.rules
- # Forcibly kills sleep command invoked by the udev rule before restarting,
- # otherwise systemctl restart below will takes longer.
- killall -KILL sleep
+ killall --regexp '(|/usr/bin/)sleep'
udevadm control --reload
ip link del "$IFNAME"
}
grep -q -F 'ID_PROCESSING=1' "/run/udev/data/n${IFINDEX}"
# Forcibly kill sleep command invoked by the udev rule to finish processing the add event.
-killall sleep
+killall --regexp '(|/usr/bin/)sleep'
udevadm settle --timeout=30
# Check if ID_PROCESSING flag is unset, and the device units are active.
# Check that the surviving services are still around
test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive.service)" = "active"
- test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
+ if [[ ! -L $(command -v sleep) ]]; then
+ test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
+ fi
test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive-sigterm.service)" != "active"
test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive.service)" != "active"
[[ ! -e /run/credentials/TEST-82-SOFTREBOOT-nosurvive.service ]]
- assert_eq "$(cat /run/credentials/TEST-82-SOFTREBOOT-survive-argv.service/preserve)" "yay"
+ if [[ ! -L $(command -v sleep) ]]; then
+ assert_eq "$(cat /run/credentials/TEST-82-SOFTREBOOT-survive-argv.service/preserve)" "yay"
+ fi
# There may be huge amount of pending messages in sockets. Processing them may cause journal rotation and
# removal of old archived journal files. If a journal file is removed during journalctl reading it,
# Check that the surviving services are still around
test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive.service)" = "active"
- test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
+ if [[ ! -L $(command -v sleep) ]]; then
+ test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
+ fi
test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive-sigterm.service)" != "active"
test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive.service)" != "active"
# Check that the surviving services are still around
test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive.service)" = "active"
- test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
+ if [[ ! -L $(command -v sleep) ]]; then
+ test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
+ fi
test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive-sigterm.service)" != "active"
test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive.service)" != "active"
# '@', and the second will use SurviveFinalKillSignal=yes. Both should survive.
# By writing to stdout, which is connected to the journal, we also ensure logging doesn't break across
# soft reboots due to journald being temporarily stopped.
- systemd-run --service-type=notify --unit=TEST-82-SOFTREBOOT-survive-argv.service \
- --property SurviveFinalKillSignal=no \
- --property IgnoreOnIsolate=yes \
- --property DefaultDependencies=no \
- --property After=basic.target \
- --property "Conflicts=reboot.target kexec.target poweroff.target halt.target emergency.target rescue.target" \
- --property "Before=reboot.target kexec.target poweroff.target halt.target emergency.target rescue.target" \
- --property SetCredential=preserve:yay \
- "$survive_argv"
+ # Note, when coreutils is built with --enable-single-binary=symlinks, unfortunately we cannot freely rename
+ # sleep command, hence we cannot test the feature.
+ if [[ ! -L $(command -v sleep) ]]; then
+ systemd-run --service-type=notify --unit=TEST-82-SOFTREBOOT-survive-argv.service \
+ --property SurviveFinalKillSignal=no \
+ --property IgnoreOnIsolate=yes \
+ --property DefaultDependencies=no \
+ --property After=basic.target \
+ --property "Conflicts=reboot.target kexec.target poweroff.target halt.target emergency.target rescue.target" \
+ --property "Before=reboot.target kexec.target poweroff.target halt.target emergency.target rescue.target" \
+ --property SetCredential=preserve:yay \
+ "$survive_argv"
+ fi
# shellcheck disable=SC2016
systemd-run --service-type=exec --unit=TEST-82-SOFTREBOOT-survive.service \
--property TemporaryFileSystem="/run /tmp /var" \