mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: alice <alice@ayaya.dev>
Cc: musl@lists.openwall.com, "yubing (C)" <yubing12@huawei.com>,
	liudongxu <liudongxu3@huawei.com>,
	"wangyunhe (A)" <wangyunhe@huawei.com>,
	qiuguorui <qiuguorui1@huawei.com>,
	"Wanglieming (VRP SSP)" <wanglieming@huawei.com>
Subject: Re: [musl] Time zone has not updated after call tzset()
Date: Sat, 11 Feb 2023 09:42:21 -0500	[thread overview]
Message-ID: <20230211144220.GG4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <CQFT11F50VT0.PKIXH946RVEX@sumire>

On Sat, Feb 11, 2023 at 03:30:58PM +0100, alice wrote:
> On Sat Feb 11, 2023 at 3:20 PM CET, Rich Felker wrote:
> > On Sat, Feb 11, 2023 at 03:10:40PM +0100, alice wrote:
> > > On Sat Feb 11, 2023 at 7:53 AM CET, zhoujingqiang (A) wrote:
> > > > Hello,
> > > >
> > > > Normally, /etc/localtime is a soft link to a file that stores time zone
> > > > information.
> > > >
> > > > Without setting the TZ environment variable, I change the time zone by
> > > > changing the file linked to /etc/localtime. After calling tzset(), I find that
> > > > the time zone does not change. The test code is as follows:
> > > 
> > > musl does not support changing the timezone while running.
> > > see https://www.openwall.com/lists/musl/2017/06/09/9 ,
> > > for a response to an identical bug report
> > > 
> > > tl;dr without semantics: you have to restart a running process to get a new
> > > timezone.
> >
> > This is not quite accurate. It does, but only via application intent,
> > in the form of changing its value of TZ. It does not re-scan files if
> > the application doesn't do that, for two important reasons:
> 
> yes, with the semantics, something like:
> 
>  setenv("TZ", "something", 0);
>  tzset();
>  unsetenv("TZ");
> 
> will update to a new /etc/localtime symlink. it's mentioned in
> https://marc.info/?l=musl&m=141374003126007&w=2
> from the above thread.
> 
> (apologies, i worded that poorly; what i mean is you cannot rely on /
> etc/localtime being read on update (without the hack above), which was the
> question. setenv("TZ") is also supported, of course.)

One small note: if you unsetenv afterwards like that, you'll never get
to use the newly selected zone since the next tz-using operation will
implicitly perform another tzset (as required by POSIX).

Rich

      reply	other threads:[~2023-02-11 14:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-11  6:53 zhoujingqiang (A)
2023-02-11 14:10 ` alice
2023-02-11 14:20   ` Rich Felker
2023-02-11 14:30     ` alice
2023-02-11 14:42       ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230211144220.GG4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=alice@ayaya.dev \
    --cc=liudongxu3@huawei.com \
    --cc=musl@lists.openwall.com \
    --cc=qiuguorui1@huawei.com \
    --cc=wanglieming@huawei.com \
    --cc=wangyunhe@huawei.com \
    --cc=yubing12@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).