Skip to content
Snippets Groups Projects
Commit 1f2f148c authored by H William Welliver's avatar H William Welliver
Browse files

rusage: reinitialize mach clock service after fork() on darwin

parent d29440a6
No related branches found
No related tags found
No related merge requests found
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#endif #endif
#include "pike_error.h" #include "pike_error.h"
#include "pike_threadlib.h"
/* /*
* Here comes a long blob with stuff to see how to find out about * Here comes a long blob with stuff to see how to find out about
* cpu usage. * cpu usage.
...@@ -832,6 +833,12 @@ void init_rusage (void) ...@@ -832,6 +833,12 @@ void init_rusage (void)
{ {
#ifdef HAVE_HOST_GET_CLOCK_SERVICE #ifdef HAVE_HOST_GET_CLOCK_SERVICE
init_mach_clock(); init_mach_clock();
/* mach ports are invalid across fork() so we should re-initialize
the mach clock service in the child. macOS 10.12+ enforce
this requirement
*/
th_atfork(NULL, NULL, init_mach_clock);
#elif defined (MIGHT_HAVE_POSIX_REALTIME_GRT) #elif defined (MIGHT_HAVE_POSIX_REALTIME_GRT)
/* Always exists according to POSIX - no need to check with sysconf. */ /* Always exists according to POSIX - no need to check with sysconf. */
get_real_time_impl = posix_realtime_grt_impl; get_real_time_impl = posix_realtime_grt_impl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment