3

Noticed something strange while working with a raspberry pi.

Using pkill with no options allows me to run other commands afterwards in the same line, but if I use the option -f, then subsequent commands are ignored. Does anyone know why?

$ ssh [email protected] "pkill -f blablabla ; echo yeaaaah"
[email protected]'s password:


$ ssh [email protected] "pkill blablabla ; echo yeaaaah"
[email protected]'s password:
yeaaaah

It makes no difference whether process blablabla exists or not.

Marcelo
  • 31
  • 2

1 Answers1

4

Because -f allows pkill to match anywhere in the command line, it matches blablabla in the argument list of the remote shell, and kills that.

You can see what's happening if you run pgrep -af instead:

$ ssh [email protected] "pgrep -af blablabla ; echo yeaaaah"
[email protected]'s password:
29223 bash -c pgrep -af blablabla ; echo yeaaaah
yeaaaah
steeldriver
  • 78,509
  • 12
  • 109
  • 152