Link to home
Start Free TrialLog in
Avatar of Longie
Longie

asked on

Unix programming, multiple timers without sleep() or pause(), etc

Hi,

You have probably seen this question 1,000,000 times already, but I am unable to find any man page or document/post that answers my question.

I have recently made some IRC Services, and everything seems up to scratch. The only thing I cannot figure out is timers. At the moment I have made a _very_ newb substitute by chucking things in a structure and every time it parses information from the IRCd it checks which timers need executing and which expire, etc. Only this causes problems in other areas due to services having to pong the IRCd and sleep() for one second (as data is continuously processed and I didn't want the load average to go through the roof). For some odd reason it creates really weird segmentation faults.

I think I am looking at setitimer() and alarm(), but I can't seem to work out exactly what I need to be doing for my needs. Basically, the services run in the background (forked) and I need a few timers to be set that perform commands, like nick expiries, channel bans, etc. I don't really want to use sleep() or anything because IRCservices shouldn't need sleeping, so I was thinking something along the lines of creating a child process that runs, I think you use the above proc's i mentioned above together with sigalarms, but I'm not really sure. I haven't touched this area of C programming before.

If someone could please point me in the direction of creating timers like this, it would be much appreciated.

Thanks for your time,

Daniel Wallace
ASKER CERTIFIED SOLUTION
Avatar of chris_calabrese
chris_calabrese

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by  chris_calabrese

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

liddler
EE Cleanup Volunteer