this should work  since ping does not spawn subprocesses but be aware  process kill will kill the shell process  but the cmd could still be running  in the case where the command spawned additional processes within the shell a nice stackoverflow discussion for reference 