In production on the cluster, we get output like this:
1 process1 22 process2 333 process3
That is, the PIDs are right-aligned. In this case, the explode(...) splits the line " 1 process1" on the first space, and we end up with an empty PID.
We later try to kill PID 0, which kills us.
Instead, trim.
Also, be slightly more liberal in splitting.