From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 10 19:17:34 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 780B7106566C for ; Mon, 10 Aug 2009 19:17:34 +0000 (UTC) (envelope-from prvs=1466d23fa6=brian@FreeBSD.org) Received: from idcmail-mo1so.shaw.ca (idcmail-mo1so.shaw.ca [24.71.223.10]) by mx1.freebsd.org (Postfix) with ESMTP id 399E58FC3F for ; Mon, 10 Aug 2009 19:17:33 +0000 (UTC) Received: from pd3ml1so-ssvc.prod.shaw.ca ([10.0.141.140]) by pd2mo1so-svcs.prod.shaw.ca with ESMTP; 10 Aug 2009 12:49:22 -0600 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.0 c=1 a=0zvlh2TQcw8A:10 a=MJPcHhXccCG8eBs0us8XwA==:17 a=MMwg4So0AAAA:8 a=6I5d2MoRAAAA:8 a=6hh7W_hZ7X0qDfwzBfMA:9 a=YCZjTytjJJJwVDdAdr45246NBtQA:4 a=WJ3hkfHDukgA:10 a=SV7veod9ZcQA:10 a=T4YOgqH00-KZFLD0MaUA:9 a=eMRDXprrR6sdrDxFPBONgDeBcXcA:4 Received: from unknown (HELO store.lan.Awfulhak.org) ([70.79.162.198]) by pd3ml1so-dmz.prod.shaw.ca with ESMTP; 10 Aug 2009 12:49:22 -0600 Received: from store.lan.Awfulhak.org (localhost.localdomain [127.0.0.1]) by localhost (Email Security Appliance) with SMTP id B25F8C433B5_A806BA9B; Mon, 10 Aug 2009 18:49:13 +0000 (GMT) Received: from gw.Awfulhak.org (gw.lan.Awfulhak.org [172.16.0.1]) by store.lan.Awfulhak.org (Sophos Email Appliance) with ESMTP id 6EB86C4611F_A806BA7F; Mon, 10 Aug 2009 18:49:11 +0000 (GMT) Received: from dev.lan.Awfulhak.org (brian@dev.lan.Awfulhak.org [172.16.0.5]) by gw.Awfulhak.org (8.14.3/8.14.3) with ESMTP id n7AInJMa015375; Mon, 10 Aug 2009 11:49:19 -0700 (PDT) (envelope-from brian@FreeBSD.org) Date: Mon, 10 Aug 2009 11:49:13 -0700 From: Brian Somers To: "Peter Steele" Message-ID: <20090810114913.74c0cb42@dev.lan.Awfulhak.org> In-Reply-To: References: <4A7C9738.10103@elischer.org> X-Mailer: Claws Mail 3.7.2 (GTK+ 2.16.5; i386-portbld-freebsd8.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/_tEAZ/udC5v5/KH_LLlC66F"; protocol="application/pgp-signature" Cc: freebsd-hackers@FreeBSD.org Subject: Re: How to signal a time zone change? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Aug 2009 19:17:34 -0000 --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" 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 Don't _EVER_ lose your sense of humour ! --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--