+void pty_input_func(gpointer data, gint sourcefd, GdkInputCondition condition)
+{
+ /* struct gui_data *inst = (struct gui_data *)data; */
+ char buf[4096];
+ int ret;
+
+ ret = read(sourcefd, buf, sizeof(buf));
+
+ /*
+ * Clean termination condition is that either ret == 0, or ret
+ * < 0 and errno == EIO. Not sure why the latter, but it seems
+ * to happen. Boo.
+ */
+ if (ret == 0 || (ret < 0 && errno == EIO)) {
+ exit(0);
+ }
+
+ if (ret < 0) {
+ perror("read pty master");
+ exit(1);
+ }
+ if (ret > 0)
+ from_backend(0, buf, ret);
+ term_out();
+}
+