You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
375 B

#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);
}