Re: localtime in Solaris 9 is not thread safe?
From: Andreas F. Borchert (comp.unix.solaris_at_expires-on-2005-03-16.usenet.andreas-borchert.de)
Date: 03/08/05
- Next message: Andreas F. Borchert: "Re: Proc"
- Previous message: Franklin Li: "localtime in Solaris 9 is not thread safe?"
- In reply to: Franklin Li: "localtime in Solaris 9 is not thread safe?"
- Next in thread: barts_at_smaalders.net: "Re: localtime in Solaris 9 is not thread safe?"
- Reply: barts_at_smaalders.net: "Re: localtime in Solaris 9 is not thread safe?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 8 Mar 2005 07:12:17 +0100 (CET)
On 2005-03-08, Franklin Li <pengtaoli@hotmai.com> wrote:
> I'm using pthread(C++) programming in Solaris 9 and find that localtime is
> not thread safe. Is it true?
>From the NOTES section of the manual page of ctime(3c):
The return values for ctime(), localtime(), and gmtime()
point to static data whose content is overwritten by each
call.
[...]
The asctime(), ctime(), gmtime(), and localtime() functions
are unsafe in multithread applications. The asctime_r() and
gmtime_r() functions are MT-Safe. The ctime_r(),
localtime_r(), and tzset() functions are MT-Safe in mul-
tithread applications, as long as no user-defined function
directly modifies one of the following variables: timezone,
altzone, daylight, and tzname. These four variables are not
MT-Safe to access. They are modified by the tzset() function
in an MT-Safe manner. The mktime(), localtime_r(), and
ctime_r() functions call tzset().
> Is there solution for this?
Use localtime_r() instead of localtime().
Andreas.
- Next message: Andreas F. Borchert: "Re: Proc"
- Previous message: Franklin Li: "localtime in Solaris 9 is not thread safe?"
- In reply to: Franklin Li: "localtime in Solaris 9 is not thread safe?"
- Next in thread: barts_at_smaalders.net: "Re: localtime in Solaris 9 is not thread safe?"
- Reply: barts_at_smaalders.net: "Re: localtime in Solaris 9 is not thread safe?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|