use waitpid to check daemon status