2010-03-03 18:32:03 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
/* Disable deprecation warning for fopen */
|
2010-03-03 18:49:21 +03:00
|
|
|
#pragma warning(disable: 4996)
|
2010-03-03 18:32:03 +03:00
|
|
|
|
|
|
|
/*if run serially, works fine.
|
|
|
|
If run in parallel, someone will attempt to delete
|
|
|
|
a locked file, which will fail */
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
FILE* file;
|
|
|
|
int i;
|
|
|
|
const char* fname;
|
|
|
|
if(argc >= 2)
|
|
|
|
{
|
|
|
|
fname = argv[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fname = "lockedFile.txt";
|
|
|
|
}
|
|
|
|
file = fopen(fname, "w");
|
|
|
|
|
|
|
|
for(i = 0; i < 10000; i++)
|
|
|
|
{
|
|
|
|
fprintf(file, "%s", "x");
|
|
|
|
fflush(file);
|
|
|
|
}
|
|
|
|
fclose(file);
|
|
|
|
return remove(fname);
|
|
|
|
}
|