diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-05-15 14:14:43 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-05-16 11:42:26 -0400 |
commit | 5fd4fa21d3852525096ceaa5ac4f64d78ac99de7 (patch) | |
tree | af3599ad7667f3e8c3082eb1724fc46533ffdd48 /src/color.h | |
parent | 0a8246ed6a5444f424219831a233a334417e38eb (diff) | |
download | bfs-5fd4fa21d3852525096ceaa5ac4f64d78ac99de7.tar.xz |
ctx: Try to reset TTY state when terminating abnormally
Fixes: https://github.com/tavianator/bfs/issues/138
Diffstat (limited to 'src/color.h')
-rw-r--r-- | src/color.h | 7 |
1 files changed, 7 insertions, 0 deletions
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 |