Assure files are written atomically
drahnr opened this issue · comments
Bernhard Schuster commented
Describe the bug
When hitting [CTRL] + C
while writing file changes to disk.
To Reproduce
Steps to reproduce the behavior:
- Run
cargo spellcheck fix
[CTRL]+C
while theBandaids
are applied + written to disk.
Expected behavior
Assure the content is written in it's entirety.
Screenshots
Please complete the following information:
- System:
- Obtained:
- Version:
Additional context
Bernhard Schuster commented
Possible solution:
- do not act upon any signal directly if file writing is active
- store a atomic u16 to defer the signal handling
- evaluate after each file
- re-attach the original signal handler after file writing is complete