/tmp file duration program questions.

A JETSON News User cosc6bp at elroy.uh.edu
Tue Feb 6 13:17:47 AEST 1990


I am writing a program that will collect data on the number of files in
the /tmp directory, and their lifetimes.  I am going to do it by the 
following 'snapshot' method:

  1) execute 'ls /tmp' 
  2) collect the output from ls either one at a time, or all at once.
  3) compare it to an array or linked list of filenames already 
  existing in /tmp.
  4) Based on 3) add new file names to the list.
  5) Also based on 3) write to a file the duration a file lasted that no 
  longer exists in the /tmp directory and delete the name from the array
  or linked list. 

It would do the above in a forever loop until we decide to kill it.

My questions are as follows:

  . What command would I use to execute 'ls /tmp' from C?
  . What is the most convenient way of routing the output from
  'ls /tmp' back into the program so that it could be compared to the
  array or linked list?  I think that a one line at a time feed would 
  be best.

Thanks for your interest,

Ignacio Valdes - U of H - Home for the moment, of Andre Ware  



More information about the Comp.lang.c mailing list