int save_errno = errno; pid_t pid; int status;  do { pid = waitpid(-1, &status, WNOHANG); if (pid == pty_child_pid && (WIFEXITED(status) || WIFSIGNALED(status))) { pty_exit_code = status; pty_child_dead = TRUE; } } while(pid > 0); errno = save_errno;
write(pty_signal_pipe[1], "x", 1);
static void sigchld_handler(int signum){    int save_errno = errno;    pid_t pid;    int status;    do {	pid = waitpid(-1, &status, WNOHANG);	if (pid == pty_child_pid && (WIFEXITED(status) || WIFSIGNALED(status))) {	    pty_exit_code = status;	    pty_child_dead = TRUE;	}    } while(pid > 0);    errno = save_errno;}