replace global error detection for local ones, so pkill failure won't cause script to exit