Make is_pid_running function return more conisten results by using isvalidpid