using "kill -0" instead of "ps h"; avoiding "$?" because of "sh -e"; minor refactoring