Thank you Rich.
I tried that and also logged the exit codes.
Interestingly, the exit codes of
pgrep -f 'regex'
and
pgrep -f 'regex' >/dev/null
are different ("1 1 1 1 1 ..." in the first case, "1 0 0 0 0 ..." in the second case). The expected exit codes are the second set.
Since the exit code of a command should not depend on where its output is going, I think I found a bug in pgrep. I'll contact the developers to inquire and will report back here with what they say.