2009-09-23 19:38:37 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2009-09-23 22:07:57 +04:00
|
|
|
/*if run serially, works fine.
|
|
|
|
If run in parallel, someone will attempt to delete
|
|
|
|
a locked file, which will fail */
|
|
|
|
int main(void)
|
2009-09-23 19:38:37 +04:00
|
|
|
{
|
|
|
|
FILE* file;
|
|
|
|
int i;
|
|
|
|
const char* fname = "lockedFile.txt";
|
|
|
|
file = fopen(fname, "w");
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (i = 0; i < 10000; i++) {
|
2009-09-23 19:38:37 +04:00
|
|
|
fprintf(file, "%s", "x");
|
|
|
|
fflush(file);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-23 19:38:37 +04:00
|
|
|
fclose(file);
|
|
|
|
return remove(fname);
|
|
|
|
}
|