[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: deleting content of /tmp



On Sun, Mar 25, 2007 at 10:00:46AM -0300, Jorge Peixoto de Morais Neto wrote:
> >
> >
> >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()?

No difference, really:

    If path specifies a directory, remove(path) is the equivalent of
    rmdir(path).  Otherwise, it is the equivalent of unlink(path).

Regards,

-Roberto
-- 
Roberto C. Sánchez
http://people.connexer.com/~roberto
http://www.connexer.com

Attachment: signature.asc
Description: Digital signature


Reply to: