wait for communication with closing program and close the stdin/out pipes