This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/155] New: tzset not called frequently enough by localtime() and friends
- From: "ballen at gravity dot phys dot uwm dot edu" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 12 May 2004 01:09:16 -0000
- Subject: [Bug libc/155] New: tzset not called frequently enough by localtime() and friends
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
Suppose that a daemon logs information every ten minutes using syslog(3).
Part of the syslog output includes a timestamp, in the local time zone.
Now suppose that the user takes the machine (laptop) and flies to a new
timezone, then changes /etc/localtime to reflect the new timezone. The daemon
(which has not been stopped and is still running) will continue to make syslog
entries using the OLD timezone.
This is because localtime() calls tzset on first invocation to learn the
timezone but then caches that information. However it's not enough to see if
the TZ variable changes. If TZ is not set then one also needs to check
/etc/localtime before each call to see if THAT has changed.
See bug number 48184 at http://bugs.debian.org for a similar report.
To reproduce the bug:
(1) unset TZ environment variable in shell
(2) run program below
(3) while program is running, change /etc/localtime to a new timezone.
Note that localtime printed does NOT reflect this change.
#include <stdio.h>
#include <time.h>
#include <unistd.h>
int main() {
time_t epochnow;
struct tm *timenow;
if (getenv("TZ")) {
fprintf(stderr,"To demonstrate this bug, you must unset the TZ environment
variable\n");
return 1;
}
while (1) {
time(&epochnow);
timenow=localtime(&epochnow);
printf("Time is %s", asctime(timenow));
sleep(5);
}
return 0;
}
--
Summary: tzset not called frequently enough by localtime() and
friends
Product: glibc
Version: 2.3.2
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: ballen at gravity dot phys dot uwm dot edu
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: i386-redhat-linux-gnu
GCC host triplet: i386-redhat-linux-gnu
GCC target triplet: i386-redhat-linux-gnu
http://sources.redhat.com/bugzilla/show_bug.cgi?id=155
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.