You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »


#include <stdio.h>

int main(int argc, char* argv) {
  FILE* first;
  FILE* second;

  char* buf1[10];
  char* buf2[10];

  first = fopen("a.in", "r");

  unlink("a.in");
  second = fopen("a.in", "r");
  if (second) {
    printf("Good OPEN\n");
  } else {
    printf("Bad OPEN\n");
  }

  fread(buf1, sizeof(char), 10, first);

  printf("First: %s\n", buf1);

  fread(buf2, sizeof(char), 10, second);

  printf("Second: %s\n", buf2);

}

 From 'man 2 unlink':
BUGS
       Infelicities in the protocol underlying NFS can cause the unexpected disappearance of files which are still being used.

  • No labels