]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[window] Handle disconnected tty fd better
authorRay Strode <rstrode@redhat.com>
Mon, 10 Aug 2009 17:47:41 +0000 (13:47 -0400)
committerRay Strode <rstrode@redhat.com>
Mon, 10 Aug 2009 17:47:41 +0000 (13:47 -0400)
Right now if we ever get a hangup from the mainloop
on the tty fd then the window's fd watch on the tty
becomes invalid and we will ultimately crash when
trying to disconnect the watch later.

This commit sets the watch to NULL if a hang up happens,
and adds some debug spew.

src/libplybootsplash/ply-window.c

index 36a3c136a171ab72f7f13bdb6a014dce6ada40ba..8fa60377d7c3a4727b76b79aa27d16d0a52c09b9 100644 (file)
@@ -417,6 +417,13 @@ on_key_event (ply_window_t *window)
   check_buffer_for_key_events (window);
 }
 
+static void
+on_tty_disconnected (ply_window_t *window)
+{
+  ply_trace ("tty disconnected (fd %d)", window->tty_fd);
+  window->tty_fd_watch = NULL;
+}
+
 static bool
 ply_window_set_unbuffered_input (ply_window_t *window)
 {
@@ -573,7 +580,8 @@ ply_window_open (ply_window_t *window)
     window->tty_fd_watch = ply_event_loop_watch_fd (window->loop, window->tty_fd,
                                                     PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
                                                     (ply_event_handler_t) on_key_event,
-                                                    NULL, window);
+                                                    (ply_event_handler_t) on_tty_disconnected,
+                                                    window);
 
   /* We try to open the frame buffer, but it may fail. splash plugins can check
    * to see if it's open and react accordingly