Skip to content

Conversation

@grynspan
Copy link
Contributor

…1212)

This PR modifies the Windows implementation of `spawnProcess()` so that
it sets the working directory of the new process to "C:\" (or
thereabouts). This prevents a race condition on Windows because that
system won't let you delete a directory if it's the working directory of
any process. See [The Old New
Thing](https://devblogs.microsoft.com/oldnewthing/20101109-00/?p=12323)
for a very on-the-nose blog post.

Note that we do not specify the value of the working directory in an
exit test body. A test should generally not rely on it anyway because it
is global state and any thread could change its value at any time.

I haven't written a unit test for this change because it's unclear what
I could write that would be easily verifiable, and because I don't know
what state I might perturb outside such a test by calling
`SetCurrentDirectory()`.

Resolves #1209.
(This is a speculative fix.)

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
@grynspan grynspan added this to the Swift 6.2 milestone Jul 10, 2025
@grynspan grynspan self-assigned this Jul 10, 2025
@grynspan grynspan added bug 🪲 Something isn't working windows 🪟 Windows support workaround Workaround for an issue in another component (may need to revert later) exit-tests ☠️ Work related to exit tests integration ⚙️ Integrating work to release branches labels Jul 10, 2025
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan merged commit 9ae56eb into release/6.2 Jul 11, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/1209-working-directories-are-terrible-6.2 branch July 11, 2025 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🪲 Something isn't working exit-tests ☠️ Work related to exit tests integration ⚙️ Integrating work to release branches windows 🪟 Windows support workaround Workaround for an issue in another component (may need to revert later)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants