can C access timestamps? 
Author Message
 can C access timestamps?

I'm writing a program for an organization at my school that needs to remove
all lock files on a Linux system after they have been inactive for 5
minutes.  Does C have a function that will do this?  I looked through the
K&R book, and I tried grepping through the include files on my system, but I
came up dry.  Thanks in advance.

-Dave



Tue, 28 Aug 2001 03:00:00 GMT  
 can C access timestamps?

Quote:

>I'm writing a program for an organization at my school that needs to remove
>all lock files on a Linux system after they have been inactive for 5
>minutes.  Does C have a function that will do this?  I looked through the
>K&R book, and I tried grepping through the include files on my system, but I
>came up dry.  Thanks in advance.

You access file timestamps (and other attributes) using stat(2).  You won't
find this in a K&R book, since it's Unix-specific, not portable C.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



Wed, 29 Aug 2001 03:00:00 GMT  
 can C access timestamps?
: I'm writing a program for an organization at my school that needs to remove
: all lock files on a Linux system after they have been inactive for 5
: minutes.  Does C have a function that will do this?  I looked through the
: K&R book, and I tried grepping through the include files on my system, but I
: came up dry.  Thanks in advance.

No, apart from the standard 'remove()' function.  The easiest way to do
this is to have the lockfiles contain the pid of their controlling process
in some form - then if the process is no longer running, the lockfile
can be considered obsolete.  You can then run a lockfile cleaner
intermittently from eg. cron to clear out dead lockfiles.

The easiest way to get a list of current pids is to use ps and mess
with the output.  However, some systems have specific calls you can
use.

Will



Wed, 29 Aug 2001 03:00:00 GMT  
 can C access timestamps?
man find

Quote:


>: I'm writing a program for an organization at my school that needs to
remove
>: all lock files on a Linux system after they have been inactive for 5
>: minutes.  Does C have a function that will do this?  I looked through the
>: K&R book, and I tried grepping through the include files on my system,
but I
>: came up dry.  Thanks in advance.

>No, apart from the standard 'remove()' function.  The easiest way to do
>this is to have the lockfiles contain the pid of their controlling process
>in some form - then if the process is no longer running, the lockfile
>can be considered obsolete.  You can then run a lockfile cleaner
>intermittently from eg. cron to clear out dead lockfiles.

>The easiest way to get a list of current pids is to use ps and mess
>with the output.  However, some systems have specific calls you can
>use.

>Will




Sun, 09 Sep 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Newbie: separate big .cs file into small .cs files

2. Determining what canned preprocessor symbols are available

3. Beginner [Q] Using Canned File Open/Save dialog

4. Help with compiling a "canned" program

5. Canned Dialogs

6. UNIX timestamp

7. Build timestamp

8. a predefined compile-timestamp token?

9. How to maintain TimeStamp consistency across Time Zones?

10. finding file creation timestamp

11. Getting Assembly compilation timestamp

12. Decoding the VMS 64bit timestamp...

 

 
Powered by phpBB® Forum Software