do not set TZ variable if it already set; fixes #2096
Costa Tsaousis (ktsaou) committed
Apr 18, 2017 at 17:51 UTC
52f28715569ff58e95957a910dc8dc1bbf911a41
1 file changed
+3
-1
src/main.c
+3
-1
@@ -504,7 +504,9 @@ void set_global_environment() {
504
505
// avoid flood calls to stat(/etc/localtime)
506
// http://stackoverflow.com/questions/4554271/how-to-avoid-excessive-stat-etc-localtime-calls-in-strftime-on-linux
507
- setenv("TZ", config_get(CONFIG_SECTION_GLOBAL, "TZ environment variable", ":/etc/localtime"), 0);
507
+ const char *tz = getenv("TZ");
508
+ if(!tz || !*tz)
509
+ setenv("TZ", config_get(CONFIG_SECTION_GLOBAL, "TZ environment variable", ":/etc/localtime"), 0);
510
511
// set the path we need
512
char path[1024 + 1], *p = getenv("PATH");