From 984d00825056f07724403e5547aa106678297ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 19 Jun 2020 14:53:07 +0200 Subject: [PATCH] term: destroy: don't wait for PTY reading thread if it was never started --- terminal.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/terminal.c b/terminal.c index deeaa235..0c603aa3 100644 --- a/terminal.c +++ b/terminal.c @@ -1289,13 +1289,16 @@ term_destroy(struct terminal *term) tll_free(term->render.workers.queue); /* Make sure we wake up the reader thread if it is blocking on a full buffer */ - mtx_lock(&term->ptmx_read_buffer.lock); - term->ptmx_read_buffer.buf[0].len = 0; - term->ptmx_read_buffer.buf[1].len = 0; - cnd_signal(&term->ptmx_read_buffer.cond); - mtx_unlock(&term->ptmx_read_buffer.lock); + if (term->ptmx_read_buffer.thread_id != 0) { + mtx_lock(&term->ptmx_read_buffer.lock); + term->ptmx_read_buffer.buf[0].len = 0; + term->ptmx_read_buffer.buf[1].len = 0; + cnd_signal(&term->ptmx_read_buffer.cond); + mtx_unlock(&term->ptmx_read_buffer.lock); + + thrd_join(term->ptmx_read_buffer.thread_id, NULL); + } - thrd_join(term->ptmx_read_buffer.thread_id, NULL); cnd_destroy(&term->ptmx_read_buffer.cond); mtx_destroy(&term->ptmx_read_buffer.lock); free(term->ptmx_read_buffer.buf[0].data);