Skip to content

GH-49146: [C++] Add option to disable atfork handlers#49148

Draft
pitrou wants to merge 1 commit intoapache:mainfrom
pitrou:gh49146-disable-atfork-handlers
Draft

GH-49146: [C++] Add option to disable atfork handlers#49148
pitrou wants to merge 1 commit intoapache:mainfrom
pitrou:gh49146-disable-atfork-handlers

Conversation

@pitrou
Copy link
Member

@pitrou pitrou commented Feb 4, 2026

Rationale for this change

The atfork handlers we register in Arrow C++ are generally useful if the Arrow APIs are meant to be used from the child process, but they also have the unfortunate effect of executing non-async-signal-safe code in the child process even if Arrow is not be used there. That is not allowed by POSIX if the parent process is multi-threaded.

There are situations where fork() is only called just before exec(), and therefore it is not necessary to run any atfork handler.

What changes are included in this PR?

  1. Add a GetEnvVarInteger utility function to automate parsing of a numeric environment variable
  2. Add basic unit tests for our APIs for getting and setting environment variables
  3. Add an environment variable ARROW_REGISTER_ATFORK to disable the registration of atfork handlers at runtime

Are these changes tested?

The new environment variable cannot be easily tested automatically, so I've checked it manually.

Are there any user-facing changes?

No, only a new feature.

@pitrou pitrou force-pushed the gh49146-disable-atfork-handlers branch from 07d10a1 to a9c3279 Compare February 4, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant