0

I want to wrap my command in a systemd-run and wait on it, redirect the logs to stdout and collect the exit status of the command.

I want to systemd-run --remain-after-exit because I want to collect it later, and I also want systemd-run --wait to exit after the process has finished.

Doing plain systemd-run --wait --pipe does not work, because in a case when the process is systemctl --user killed the unit is garbage collected by systemd and dissapears. After systemdctl --user kill then systemd-run always returns the exit code 1 irrelevant of the process exit code. In case it received a signal, I want the exit code of the child process, not 1.

The following works for all exit codes except for zero:

systemctl --user stop text ; systemctl --user reset-failed text
systemd-run --service-type=oneshot -r --user --wait --pipe --unit=text bash -xc 'exit 0'

The command just blocks. Can it not block and just exit?

KamilCuk
  • 850
  • 8
  • 16

0 Answers0