From owner-freebsd-questions@FreeBSD.ORG Fri Aug 7 17:29:21 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 50C52106566B for ; Fri, 7 Aug 2009 17:29:21 +0000 (UTC) (envelope-from psteele@webmail.maxiscale.com) Received: from k2smtpout04-01.prod.mesa1.secureserver.net (k2smtpout04-01.prod.mesa1.secureserver.net [64.202.189.166]) by mx1.freebsd.org (Postfix) with SMTP id 2AF8E8FC0A for ; Fri, 7 Aug 2009 17:29:20 +0000 (UTC) Received: (qmail 18762 invoked from network); 7 Aug 2009 17:29:20 -0000 Received: from unknown (HELO owa.webmail.maxiscale.com) (72.167.52.135) by k2smtpout04-01.prod.mesa1.secureserver.net (64.202.189.166) with ESMTP; 07 Aug 2009 17:29:20 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Fri, 7 Aug 2009 10:34:56 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: How is time zone change signalled? Thread-Index: AcoXb7JvCUMCOOMhTa+EYDJw52np1QAEDwhg References: <4A7C4007.9000506@FreeBSD.org> From: "Peter Steele" To: Subject: RE: How is time zone change signalled? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Aug 2009 17:29:21 -0000 >Did you try unsetting TZ and then calling tzset()? The man page implies that doing so will force a reread of /etc/localtime >(http://www.freebsd.org/cgi/man.cgi?query=3Dtzset&sourceid=3Dopensearch)= : > >"The tzset() function initializes time conversion information used by the library routine localtime(3). The environment variable TZ specifies how this is done. > >If TZ does not appear in the environment, the best available approximation to local wall clock time, as specified by the tzfile(5)-format file /etc/localtime is used." > >I haven't tested it, though, and I'm no timezone expert, so I may be completely off-base! Yes, I've tried the tzset function. I'm basically doing the equivalent of these steps after the Java app changes time zone and updates /etc/localtime: time_t date =3D time(NULL); unsetenv("TZ"); tzset(); printf("time zone is %s/%s", tzname[0], tzname[1]); struct tm* locTime =3D localtime(&date); printf("%02d:%02d:%02d", locTime->tm_hour, locTime->tm_min, locTime->tm_sec); The time printed is still based on the old time zone though. The tzname variable that is set by tzset() still shows for example EDT even if I have just changed the time zone to PDT. If I stop and restart the C app, the time is correct, and tzname is then PDT instead of EDT. I'm very puzzled on what I'm supposed to do to kick start the C time zone. We do not want to have to restart our C apps for something as trivial as this.