Skip to content

Commit

Permalink
OSRPJContextHolder: call pthread_atfork() once for the process
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Dec 4, 2023
1 parent 8e63d88 commit 5238ac8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ogr/ogr_proj_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,17 @@ struct OSRPJContextHolder
#endif
{
#if HAVE_PTHREAD_ATFORK
pthread_atfork(nullptr, nullptr, ForkOccurred);
static std::once_flag flag;
std::call_once(
flag,
[]()
{
if (pthread_atfork(nullptr, nullptr, ForkOccurred) != 0)
{
CPLError(CE_Failure, CPLE_OutOfMemory,
"pthread_atfork() in ogr_proj_p failed");
}
});
#endif
init();
}
Expand Down

0 comments on commit 5238ac8

Please sign in to comment.