From 43cd776d7dc8ac573262f8459edeb1c1f5f3cd09 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 7 Mar 2024 16:18:32 -0500 Subject: xtime: Call tzset() from main() instead of lazily POSIX specifies[1] that If a thread accesses tzname, daylight, or timezone directly while another thread is in a call to tzset(), or to any function that is required or allowed to set timezone information as if by calling tzset(), the behavior is undefined. So calling it lazily from arbitrary threads is risky. [1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tzset.html --- src/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 1ddbc54..16a2576 100644 --- a/src/main.c +++ b/src/main.c @@ -55,6 +55,7 @@ #include #include #include +#include #include /** @@ -121,6 +122,9 @@ int main(int argc, char *argv[]) { locale_err = errno; } + // Apply the environment's timezone + tzset(); + // Parse the command line struct bfs_ctx *ctx = bfs_parse_cmdline(argc, argv); if (!ctx) { -- cgit v1.2.3