Hello,
I have encountered unexpected behavior when using flock.
It will block forever, but to my understanding it should not.
I've attached a simple program that would trigger the behavior.
Regards,
Alex
#include <stdio.h>
#include <unistd.h>
#include <sys/file.h>
FILE *fp;
void main() {
unlink("a"); unlink("b");
fp = fopen("a", "wb"); // file a
printf("lock a\n");
flock(fileno(fp), LOCK_EX);
fwrite("TEST", sizeof(char), 4, fp);
printf("unlock a\n");
flock(fileno(fp), LOCK_UN);
fclose(fp);
fp = fopen("b", "wb"); // file b
printf("lock b\n");
flock(fileno(fp), LOCK_EX); // hang
fwrite("TEST", sizeof(char), 4, fp);
printf("unlock b\n");
flock(fileno(fp), LOCK_UN);
fclose(fp);
}
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple