blob: 7942b722660f6a031fb85ed8c223d7307d4b6302 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#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()
{
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);
}
|