# std.Build.Step.Compile: fix race condition in args file creation · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/d4df65e35504bc4a2fa500e03fbbaf95910035c8)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: d4df65e35504bc4a2fa500e03fbbaf95910035c8

Requested commit: d4df65e35504bc4a2fa500e03fbbaf95910035c8

Commit: d4df65e35504bc4a2fa500e03fbbaf95910035c8

Tree: 23528356b265434f0ec24e0220991880054db138

Author: Ian Johnson

Committer: Matthew Lugg

## Message

```
std.Build.Step.Compile: fix race condition in args file creation

Fixes #23993

Previously, if multiple build processes tried to create the same args file, there was a race condition with the use of the non-atomic `writeFile` function which could cause a spawned compiler to read an empty or incomplete args file. This commit avoids the race condition by first writing to a temporary file with a random path and renaming it to the desired path.

```

## Parents

- [d57b1e3552bae31c535a39d165608127579b9b08](https://git.cafe/gitcafe/zig/commit/d57b1e3552bae31c535a39d165608127579b9b08?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/d4df65e35504bc4a2fa500e03fbbaf95910035c8?format=markdown)
