[lug] changing timezone of a running process
Scott Herod
herod at dimensional.com
Mon Nov 3 16:51:27 MST 2003
This one should be relatively simple. How do I inform a running process
that the timezone has changed. For example compile the code below then
while it's running use timeconfig as root to set the timezone to something
else.
Thanks,
Scott
#include <iostream>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
int main()
{
struct timeval tv;
struct tm time;
while ( true )
{
sleep ( 2 );
tzset(); // Does this reset?
gettimeofday( &tv, NULL );
localtime_r( &tv.tv_sec, &time );
std::cerr << "Offset " << time.tm_gmtoff << std::endl;
}
}
More information about the LUG
mailing list