#include #define DIR "/media/nfs4import/" int main(void) { FILE *f1; FILE *f2; char b[1024]; int i; // create file1 f1 = fopen(DIR "file1.txt", "w"); fwrite("test\n", 5, 1, f1); close(f1); // open file1 in read mode f1 = fopen(DIR "file1.txt", "r"); for (i = 0; i < 1; i++) { // open file2 in write mode and close it f2 = fopen(DIR "file2.txt", "w"); fclose(f2); // open file2 in read mode and close it // this causes the leak of a file descriptor on the server // just watch /proc/sys/fs/file-nr on the server f2 = fopen(DIR "file2.txt", "r"); fclose(f2); } fclose(f1); return 0; }