Fix macOS tmpdir cleanup race caused by system daemons creating ~/Library#3515
Open
sean- wants to merge 1 commit intothought-machine:masterfrom
Open
Fix macOS tmpdir cleanup race caused by system daemons creating ~/Library#3515sean- wants to merge 1 commit intothought-machine:masterfrom
sean- wants to merge 1 commit intothought-machine:masterfrom
Conversation
e9d5f81 to
f507195
Compare
…rary On macOS, system daemons (cfprefsd, lsd) automatically create $HOME/Library/ for any process whose HOME they observe. Since the build env sets HOME=tmpDir, these daemons can recreate Library/ inside a target's temporary directory during or just after cleanup, causing os.RemoveAll to fail with ENOTEMPTY. Handle this with a platform-specific cleanTmpDir that detects the Library/ directory on ENOTEMPTY and retries removal with bounded backoff. Non-Darwin platforms get a zero-overhead passthrough.
f507195 to
a0464d7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On macOS, system daemons (
cfprefsd,lsd) automatically create$HOME/Library/for any process whoseHOMEthey observe. Since the build env setsHOME=tmpDir, these daemons can recreateLibrary/inside a target's temporary directory during or just after cleanup, causingos.RemoveAllto fail withENOTEMPTY.Handle this with a platform-specific
cleanTmpDirthat detects theLibrary/directory onENOTEMPTYand retries removal with bounded backoff. Non-Darwin platforms get a zero-overhead passthrough.Without this, building plz on macOS would result in output like:
Which, while harmless, is not helpful for developers starting to use plz.