+static gboolean
+readpipe(GIOChannel *s, GIOCondition ioc, gpointer unused)
+{
+ static char msg[MSGBUFSZ], msgsz;
+ GError *gerr = NULL;
+
+ if (g_io_channel_read_chars(s, msg, sizeof(msg), NULL, &gerr) !=
+ G_IO_STATUS_NORMAL) {
+ fprintf(stderr, "surf: error reading pipe: %s\n",
+ gerr->message);
+ g_error_free(gerr);
+ return TRUE;
+ }
+ if ((msgsz = msg[0]) < 3) {
+ fprintf(stderr, "surf: message too short: %d\n", msgsz);
+ return TRUE;
+ }
+
+ switch (msg[2]) {
+ case 'i':
+ close(pipein[1]);
+ close(pipeout[0]);
+ break;
+ }
+
+ return TRUE;
+}
+