fix: Prevent daemonize mode from crashing upload process #1104
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In macOS 10.13, changes to Objective-C runtime forbid calling ObjC code before and after forking the process. If we want to do that, and we need to, due to moving
sentry-cli
process to the background during XCode artifacts upload, we need to perform all those calls after we daemonize ourselves. This forces us to not spawn any processes, nor call any ObjC-compiled code (like cURL) before we actually get to that branch.The thing that's detaching us is
MayDetach::wrap
viaMayDetach::may_detach
function.If we call any cURL code or spawn any process before-hand, it will result in the background process crashing with:
This PR does the following:
Build Script
, and not part of the larger mechanism, thus we never expect it to be interrupted.ref: https://www.wefearchange.org/2018/11/forkmacos.rst.html
ref: http://sealiesoftware.com/blog/archive/2017/6/5/Objective-C_and_fork_in_macOS_1013.html