mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-12 05:34:01 -04:00
notify: don't close FD 0
This fixes a regression where closing a terminal instance, or hard- or soft-resetting a terminal caused FD 0 to be closed. This meant it became re-usable. Usually, by memfd_create() when allocating a new surface buffer. So far nothing _really_ bad has happened. But what if FD 0 is now used by a memfd, and we close _another_ terminal instance? This causes our memfd to be closed. And then, when e.g. trying to scroll the terminal content: fallocate() fails with bad FD.
This commit is contained in:
parent
a3ad740251
commit
0a5ba708e4
3 changed files with 11 additions and 4 deletions
9
notify.c
9
notify.c
|
|
@ -505,10 +505,13 @@ notify_icon_del(struct terminal *term, const char *id)
|
||||||
void
|
void
|
||||||
notify_icon_free(struct notification_icon *icon)
|
notify_icon_free(struct notification_icon *icon)
|
||||||
{
|
{
|
||||||
if (icon->tmp_file_fd >= 0)
|
if (icon->tmp_file_name != NULL) {
|
||||||
close(icon->tmp_file_fd);
|
|
||||||
if (icon->tmp_file_name != NULL)
|
|
||||||
unlink(icon->tmp_file_name);
|
unlink(icon->tmp_file_name);
|
||||||
|
if (icon->tmp_file_fd >= 0) {
|
||||||
|
xassert(icon->tmp_file_fd > 0); // DEBUG
|
||||||
|
close(icon->tmp_file_fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free(icon->id);
|
free(icon->id);
|
||||||
free(icon->symbolic_name);
|
free(icon->symbolic_name);
|
||||||
|
|
|
||||||
2
shm.c
2
shm.c
|
|
@ -255,7 +255,7 @@ instantiate_offset(struct buffer_private *buf, off_t new_offset)
|
||||||
|
|
||||||
void *mmapped = MAP_FAILED;
|
void *mmapped = MAP_FAILED;
|
||||||
struct wl_buffer *wl_buf = NULL;
|
struct wl_buffer *wl_buf = NULL;
|
||||||
pixman_image_t **pix = xcalloc(buf->public.pix_instances, sizeof(*pix));
|
pixman_image_t **pix = xcalloc(buf->public.pix_instances, sizeof(pix[0]));
|
||||||
|
|
||||||
mmapped = (uint8_t *)pool->real_mmapped + new_offset;
|
mmapped = (uint8_t *)pool->real_mmapped + new_offset;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1330,6 +1330,10 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < ALEN(term->notification_icons); i++) {
|
||||||
|
term->notification_icons[i].tmp_file_fd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
add_utmp_record(conf, reaper, ptmx);
|
add_utmp_record(conf, reaper, ptmx);
|
||||||
|
|
||||||
if (!pty_path) {
|
if (!pty_path) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue