Setting the access/modify time on a file

Tom Haapanen tom at mims-iris.waterloo.edu
Tue Mar 13 01:30:23 AEST 1990


I wish to update a file (with an advisory lock), and then to close it,
setting the access and modify times to (almost) the same time.  Here
is what I'm attempting:

	FILE *fp;
	long times;

	fp = fopen("filename", "w");
	flock(fileno(fp), LOCK_EX);

	... much i/o to the file ...

	fflush(fp);
	times[1] = time(&times[0]) - (long)2;
	utime(mailfile, times);

	flock(fileno(fp), LOCK_UN);
	fclose(fp);

Now, at what point does the modify time get set?  the utime() call appears
to set the access time, but the modify time appears to be set AGAIN after
the access time.  Where SHOULD it get set?  And what should I do to make
sure that my access time > modify time?

The OS is IRIX 3.2 -- aka System V.3.  Thanks for any and all replies!

[ \tom haapanen -- university of waterloo -- tom at mims-iris.waterloo.edu    ]
[ "i say what i say, but i say it for myself and myself only" -- me        ]
[ "i don't even know what street canada is on"                -- al capone ]



More information about the Comp.unix.wizards mailing list