- systemd-cat -t "$cmd_name" "$@" 2>&1 &
- pid=$!
- old_int_trap="$(trap -p INT)"
- # Note, just passing along INT wont actually stop it.
- # Oddly, the log says ERROR: /script.sh returned 130
- # but it continues on.
- trap "inttrap $pid" INT
- sedscript="/$pattern$cmd_name/p;/^.{16}[^ ]+ $cmd_name\[$pid]: ([^ ]*\/)?$cmd_name: exiting with status [0-9]+\$/q"
- # debug:
- #echo "sedscript: sed -nr '$sedscript'"
- journalctl -S "4 seconds ago" -f |& sed -nr "$sedscript" 2>&1 &
+ sedscript="/$pattern$cmd_name/p;/^.{16}[^ ]+ $cmd_name\[[0-9]+]: ([^ ]*\/)?$cmd_name: exiting with status [0-9]+\$/q"
+ # We use >() so that $! is the pid of journalctl, otherwise its the sed pid and then
+ # if we kill that, it takes journalctl about 10 seconds to catch up, and we get
+ # an annoying message about job finishing then.
+ journalctl -qn2 -f &> >(sed -nr "$sedscript") &
+ # We kill this in prompt-command for the case that we ctrl-c the
+ # systemd-cat. i dont know any way to trap ctrl-c and still run the
+ # normal action for it. There might be a way, unsure.