Revision 9306a5ab28af6bb6dc2b933339ccc66764f44b12 authored by Brad King on 20 July 2022, 13:33:55 UTC, committed by Brad King on 20 July 2022, 13:33:55 UTC
1 parent 652b7c1
lockFile.c
#include <stdio.h>
/*if run serially, works fine.
If run in parallel, someone will attempt to delete
a locked file, which will fail */
int main(void)
{
FILE* file;
int i;
const char* fname = "lockedFile.txt";
file = fopen(fname, "w");
for (i = 0; i < 10000; i++) {
fprintf(file, "%s", "x");
fflush(file);
}
fclose(file);
return remove(fname);
}
Computing file changes ...