79526742

Date: 2025-03-21 23:38:38
Score: 0.5
Natty:
Report link

Leaving this as an answer as a reference for people what seems to work, but is just plain wrong:

It seems that the PID of `zfs send` is always `+1` of the PID returned by `$!`. However, it has been pointed out that this is no guarantee and thus should not be relied upon.
$!+1 might be a different process than intended, which results in the wanted process to keep running, and an unwanted process being killed.


crypt_keydata_backup=""
time while IFS= read -r line; do
    crypt_keydata_backup+="${line}"$'\n'
    if [[ "${line}" == *"end crypt_keydata"* ]]; then
        kill $(( $! + 1 )) &>/dev/null
        break
    fi
done< <(stdbuf -oL zfs send -w -p ${backup_snapshot} | stdbuf -oL zstream dump -v)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Maanloper