gracelang / minigrace

Self-hosting compiler for the Grace programming language
39 stars 22 forks source link

Compiler's output files are not written atomically #311

Closed apblack closed 4 years ago

apblack commented 4 years ago

When the compiler writes its output file, the file is created, written and closed. Hence, there is a small window when the file exists and is empty. This breaks make -j, because another process may be waiting for the file to come into existence.

What should happen is that the file is created under a temporary name (perhaps named using random bytes from the crypt package), written, and then renamed. This should work because rename is atomic. Note that the temp file should be in the same directory to be used for the output file.

apblack commented 4 years ago

Fixed in 69fcf6e42bda