Oh! That isn't your code, but that path can be wrong.
Calling tasklist/ps doesn't look like a safe practice.
I imagine adb does something similar when running the command line app in order to not run the daemon multple times?