copied in sigchld_handler from book