gint timer_func(gpointer data)
{
/* struct gui_data *inst = (struct gui_data *)data; */
+ extern int pty_child_is_dead(); /* declared in pty.c */
+
+ if (pty_child_is_dead()) {
+ /*
+ * The primary child process died. We could keep the
+ * terminal open for remaining subprocesses to output to,
+ * but conventional wisdom seems to feel that that's the
+ * Wrong Thing for an xterm-alike, so we bail out now. This
+ * would be easy enough to change or make configurable if
+ * necessary.
+ */
+ exit(0);
+ }
term_update();
return TRUE;
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <signal.h>
#include <fcntl.h>
#include <termios.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <sys/ioctl.h>
#include "putty.h"
#endif
int pty_master_fd;
+static int pty_child_pid;
+static sig_atomic_t pty_child_dead;
char **pty_argv;
+int pty_child_is_dead(void)
+{
+ return pty_child_dead;
+}
+
static void pty_size(void);
+static void sigchld_handler(int signum)
+{
+ pid_t pid;
+ int status;
+ pid = waitpid(-1, &status, WNOHANG);
+ if (pid == pty_child_pid && (WIFEXITED(status) || WIFSIGNALED(status)))
+ pty_child_dead = TRUE;
+}
+
/*
* Called to set up the pty.
*
exit(127);
} else {
close(slavefd);
+ pty_child_pid = pid;
+ pty_child_dead = FALSE;
+ signal(SIGCHLD, sigchld_handler);
}
return NULL;