Added  env and solve waitpid bug