Fix a crash when opening two terminal windows and closing the first one.
To reproduce, launch the terminal, open a second window using Ctrl-Shift-N, go back to the first window, and press Ctrl-D. The terminal's master FD gets events even after being closed, causing terminal_destroy to be called twice on the same object. To fix this, I'm adding a function to stop watching an FD.
This commit is contained in:
committed by
Kristian Høgsberg
parent
cd1d6c8f19
commit
a85292e73c
+4
-2
@@ -2578,13 +2578,15 @@ terminal_create(struct display *display)
|
|||||||
static void
|
static void
|
||||||
terminal_destroy(struct terminal *terminal)
|
terminal_destroy(struct terminal *terminal)
|
||||||
{
|
{
|
||||||
|
display_unwatch_fd(terminal->display, terminal->master);
|
||||||
window_destroy(terminal->window);
|
window_destroy(terminal->window);
|
||||||
close(terminal->master);
|
close(terminal->master);
|
||||||
wl_list_remove(&terminal->link);
|
wl_list_remove(&terminal->link);
|
||||||
free(terminal);
|
|
||||||
|
|
||||||
if (wl_list_empty(&terminal_list))
|
if (wl_list_empty(&terminal_list))
|
||||||
exit(0);
|
display_exit(terminal->display);
|
||||||
|
|
||||||
|
free(terminal);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -4346,6 +4346,12 @@ display_watch_fd(struct display *display,
|
|||||||
epoll_ctl(display->epoll_fd, EPOLL_CTL_ADD, fd, &ep);
|
epoll_ctl(display->epoll_fd, EPOLL_CTL_ADD, fd, &ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
display_unwatch_fd(struct display *display, int fd)
|
||||||
|
{
|
||||||
|
epoll_ctl(display->epoll_fd, EPOLL_CTL_DEL, fd, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
display_run(struct display *display)
|
display_run(struct display *display)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -146,6 +146,9 @@ void
|
|||||||
display_watch_fd(struct display *display,
|
display_watch_fd(struct display *display,
|
||||||
int fd, uint32_t events, struct task *task);
|
int fd, uint32_t events, struct task *task);
|
||||||
|
|
||||||
|
void
|
||||||
|
display_unwatch_fd(struct display *display, int fd);
|
||||||
|
|
||||||
void
|
void
|
||||||
display_run(struct display *d);
|
display_run(struct display *d);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user