The following little C program will illustrate: #include <stdio.h> #include <stdlib.h> int main(void) { FILE *f; f = fopen("check_my_size", "w"); int i; for (i = 0; i < 1000000; ++i) fprintf(f, "This is just filler for the file"); system("ls -lk check_my_size"); printf("Checking utilization:\n"); fflush(stdout); system("df -k"); sleep(2); printf("Unlinking file\n"); fflush(stdout); unlink("check_my_size"); system("ls -lk check_my_size"); printf("Checking utilization:\n"); fflush(stdout); system("df -k"); sleep(2); printf("Closing file\n"); fflush(stdout); fclose(f); system("ls -lk check_my_size"); printf("Checking utilization:\n"); fflush(stdout); system("df -k"); return 0; }
Why do you use unlink() instead of remove()? -- Software is like sex: it is better when it is free.