Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!samsung!aplcen!boingo.med.jhu.edu!welch.jhu.edu!ted From: ted@welch.jhu.edu (Ted Ying) Newsgroups: comp.lang.c Subject: Re: /tmp file duration program questions. Message-ID: <1990Feb6.203140.29490@welch.jhu.edu> Date: 6 Feb 90 20:31:40 GMT References: <5474.25cddf6b@elroy.uh.edu> <5368@buengc.BU.EDU> Reply-To: ted@welchlab.welch.jhu.edu (Ted Ying) Organization: Welch Medical Library, Baltimore Lines: 27 In article <5368@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes: >In article <5474.25cddf6b@elroy.uh.edu> cosc6bp@elroy.uh.edu (A JETSON News User) writes: >> >>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. >... >>My questions are as follows: >> . What command would I use to execute 'ls /tmp' from C? > >You would use system(3); but there's a better way. > Well, I would suggest using vfork(2) and execle(3) for the "ls" command. It is a better alternative than using the system(3) command as it uses less overhead. Especially since you intend to run this endlessly in the background. You really don't want the overhead of a system(3) process going continuously. Ted Ying ted@welch.jhu.edu #include Velilind's Laws of Experimentation: 1. If reproducibility may be a problem, conduct the test only once. 2. If a straight line fit is required, obtain only two data points.