Bug 103701 - timegm() manpage suggests a terrible workaround
Summary: timegm() manpage suggests a terrible workaround
Status: RESOLVED CODE_FIX
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P1 low
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-29 10:36 UTC by Stephen Hurd
Modified: 2016-03-10 23:48 UTC (History)
2 users (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Stephen Hurd 2015-08-29 10:36:07 UTC
In today's multi-threaded world, is changing an environment variable, calling tzset(), calling mktime(), changing the env variable back, and calling tzset() again really the best way to solve this problem?
Comment 1 Michael Kerrisk 2016-03-10 18:30:02 UTC
Stephen,

It's obviously not ideal. I added some words pointing out that it's not thread-safe. But, I have no further idea for changes. Do you?

Cheers,

Michael
Comment 2 Stephen Hurd 2016-03-10 20:00:33 UTC
I'm not sure why the manpage documents how to not use the function (obviously, documenting *why* not to use it makes sense.)

If there's honestly no good way to emulate timegm() in a threadsafe manner, should its use really be discouraged?
Comment 3 Mats Wichmann 2016-03-10 22:16:18 UTC
The Gnu glibc documentation has something like this in the portability notes.  Often the genesis of comments when there's a strange disclaimer in the manpage :)

I guess I'd suggest the page emphasize the UTC aspect and mention the threadsafe issue, and stop there - not try to document a workaround.
Comment 4 Michael Kerrisk 2016-03-10 23:48:14 UTC
Okay--you two convinced me. I killed the sample timegm() implementation and added mention of UTC. Thread-safety issues are covered already in ATTRIBUTES.

Note You need to log in before you can comment on or make changes to this bug.