Use a pipe to detect exit of the client program.