/tmp file duration program questions.

Ted Ying ted at welch.jhu.edu
Wed Feb 7 07:31:40 AEST 1990


In article <5368 at buengc.BU.EDU> bph at buengc.bu.edu (Blair P. Houghton) writes:
>In article <5474.25cddf6b at elroy.uh.edu> cosc6bp at 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 at welch.jhu.edu

#include <std.disclaimer.h>
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.



More information about the Comp.lang.c mailing list