From 5fd4fa21d3852525096ceaa5ac4f64d78ac99de7 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 15 May 2024 14:14:43 -0400 Subject: ctx: Try to reset TTY state when terminating abnormally Fixes: https://github.com/tavianator/bfs/issues/138 --- src/color.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/color.h') diff --git a/src/color.h b/src/color.h index 3278cd6..3550888 100644 --- a/src/color.h +++ b/src/color.h @@ -42,6 +42,8 @@ typedef struct CFILE { const struct colors *colors; /** A buffer for colored formatting. */ dchar *buffer; + /** Cached file descriptor number. */ + int fd; /** Whether the next ${rs} is actually necessary. */ bool need_reset; /** Whether to close the underlying stream. */ @@ -108,4 +110,9 @@ int cfprintf(CFILE *cfile, const char *format, ...); attr(printf(2, 0)) int cvfprintf(CFILE *cfile, const char *format, va_list args); +/** + * Reset the TTY state when terminating abnormally (async-signal-safe). + */ +int cfreset(CFILE *cfile); + #endif // BFS_COLOR_H -- cgit v1.2.3