Date: Mon, 10 Aug 2009 11:49:13 -0700 From: Brian Somers <brian@FreeBSD.org> To: "Peter Steele" <psteele@webmail.maxiscale.com> Cc: freebsd-hackers@FreeBSD.org Subject: Re: How to signal a time zone change? Message-ID: <20090810114913.74c0cb42@dev.lan.Awfulhak.org> In-Reply-To: <B8A480488C0C6849826655761349EA431F7175@owa.webmail.maxiscale.com> References: <B8A480488C0C6849826655761349EA431F716A@owa.webmail.maxiscale.com> <4A7C9738.10103@elischer.org> <B8A480488C0C6849826655761349EA431F7171@owa.webmail.maxiscale.com> <eaec67500908071423v95b7214t30a48ad3d75c3cd@mail.gmail.com> <B8A480488C0C6849826655761349EA431F7175@owa.webmail.maxiscale.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Sig_/_tEAZ/udC5v5/KH_LLlC66F Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 7 Aug 2009 15:08:16 -0700 "Peter Steele" <psteele@webmail.maxiscale= .com> wrote: > >What's the value of the TZ environment variable for the C apps? You may > need to have them read the new value from somewhere, and then rerun > tzset(). >=20 > The default value of the TZ environment variable is null. I just tried > passing the explicitly time zone value to the C app and setting TZ to > that value and that seemed to work. I would think that that I should be > able to retrieve that value from /etc/localtime as the docs imply. Guess > not. If I have to pass the time zone to the C app, then I guess that's > what I'll do... This doesn't work because of two bugs in localtime.c. The first is what you're hitting where tzset() calls tzset_basic() which calls tzsetwall_basi= c() which says: if (lcl_is_set < 0) { if (!rdlocked) _RWLOCK_UNLOCK(&lcl_rwlock); return; } If you were to have your own TZ setting and wanted to modify the file referred to by that, you'd bump into this bug in tzset_basic(): if (lcl_is_set > 0 && strcmp(lcl_TZname, name) =3D=3D 0) { if (!rdlocked) _RWLOCK_UNLOCK(&lcl_rwlock); return; } Roughly translated, localtime.c goes out of its way to never re-read the same zone file twice in a row. This is just a mistake. As you discovered, altering TZ before calling tzset() is the best way to make it work right now. If you really want to ensure that you're reading /etc/localtime, this bit of hackery works too: putenv("TZ=3D/dev/null"); tzset(); unsetenv("TZ"); tzset(); If you raise a PR and let me know the number, I'd be happy to fix this. --=20 Brian Somers <brian@Awfulhak.org> Don't _EVER_ lose your sense of humour ! <brian@FreeBSD.org> --Sig_/_tEAZ/udC5v5/KH_LLlC66F Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (FreeBSD) iQCVAwUBSoBrrg7tvOdmanQhAQIE+wQAiGkxjzzRGYzo1pB/ftgD9OpBbT8voiyH C3Ptle76G9Q9Rh9GuZnLR8ctANC5huc9xSKitPz62xvhwol1Zhn2Pd8DjKyrVtGr 2oZKN0zy0L/zPcSfBAJDcyvQCAPjDjIqR0EMqQ0u0fgjdtbiGBbuiIfE5LiT70/n IyMZijoqXWI= =+aSb -----END PGP SIGNATURE----- --Sig_/_tEAZ/udC5v5/KH_LLlC66F--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090810114913.74c0cb42>