performing a task at regular intervals

hi!

i m tryin to write a program that will perform a specific tasks after fixed interval of time.say every 1 min.
i jus donno how to go abt it.. which functions to use and so on...
i wud like to add that i am dont want to use crontab over here.
ny lead is appreciated.

thanx.

UNIX supports about 30 signals, each with a unique integer code. You can program the current process to react to a particular signal in one of these ways.

React according to the default, which is to terminate, do nothing, or possibly dump core
Ignore the signal
Execute a user-supplied signal handler function

In addition, you can program the current process to block certain signals. Blocked signals are queued and only delivered if they are unblocked.

If you want a reminder of a timeout you can set the SIGALRM signal to the current process. Write a signal handler for the same and perform your operations there.

However there are two ways of implementing UNIX signal. SYSV and BSD style. The BSD style is more efficient.

If you are looking to write a loop, then you might want to look at the sleep call as well. As in:

while(1) {
do stuff..
..
..
sleep(60); /* here you will sleep for 60 sec and then wake up and go on to do the same stuff again*/
}