void ply_terminal_free (ply_terminal_t *terminal) { if (terminal == NULL) return; if (terminal->loop != NULL) { ply_event_loop_stop_watching_for_exit (terminal->loop, (ply_event_loop_exit_handler_t) ply_terminal_detach_from_event_loop, terminal); if (terminal->number_of_reopen_tries > 0) { ply_event_loop_stop_watching_for_timeout (terminal->loop, (ply_event_loop_timeout_handler_t) ply_terminal_reopen_device, terminal); } } if (terminal->is_open) ply_terminal_close (terminal); free_vt_change_closures (terminal); free_input_closures (terminal); free (terminal->name); free (terminal); }
static bool open_device (ply_renderer_backend_t *backend) { assert (backend != NULL); assert (backend->device_name != NULL); if (!load_driver (backend)) return false; if (!ply_terminal_open (backend->terminal)) { ply_trace ("could not open terminal: %m"); return false; } if (!ply_terminal_is_vt (backend->terminal)) { ply_trace ("terminal is not a VT"); ply_terminal_close (backend->terminal); return false; } ply_terminal_watch_for_active_vt_change (backend->terminal, (ply_terminal_active_vt_changed_handler_t) on_active_vt_changed, backend); return true; }