mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 22:09:37 +00:00
Fixes issue 29539 with the workaround of initializing libnotify early by calling localtime_r in OS::InitOnce().
BUG=Fixes #29539 R=rmacnak@google.com Review-Url: https://codereview.chromium.org/2854303005 .
This commit is contained in:
parent
af7f15e633
commit
9b1412031b
|
@ -423,6 +423,21 @@ void OS::InitOnce() {
|
|||
static bool init_once_called = false;
|
||||
ASSERT(init_once_called == false);
|
||||
init_once_called = true;
|
||||
|
||||
// See https://github.com/dart-lang/sdk/issues/29539
|
||||
// This is a workaround for a macos bug, we eagerly call localtime_r so that
|
||||
// libnotify is initialized early before any fork happens.
|
||||
struct timeval tv;
|
||||
if (gettimeofday(&tv, NULL) < 0) {
|
||||
FATAL1("gettimeofday returned an error (%s)\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
tm decomposed;
|
||||
struct tm* error_code = localtime_r(&(tv.tv_sec), &decomposed);
|
||||
if (error_code == NULL) {
|
||||
FATAL1("localtime_r returned an error (%s)\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue