precise time values in a daemon.
I am wanting to write a daemon to do some monitoring, and I want to
ensure that it does its thing..which may take a variable amount of time,
at precise intervals of - say - 5 minutes.
so
while(1) {do variable time stuff - sleep 5 minutes}
is too imprecise.
But I don't want to waste cycles, checking the time..
It seems that some combination of alarm() and sleep() would work, but I
a not sure how to set up a signal handler..
is it as simple as
alarm(5 minutes)
pause()
Or do I need to set up a signal handler for the interrupt?
I would also like the daemon to be able to detect and act on kill
signals as well.
.
Relevant Pages
- Re: precise time values in a daemon.
... ensure that it does its thing..which may take a variable amount of time, ... That is too imprecise why? ... I would also like the daemon to be able to detect and act on kill ... signals as well. ... (comp.os.linux.misc) - Re: precise time values in a daemon.
... ensure that it does its thing..which may take a variable amount of time, at precise intervals of - say - 5 minutes. ... Or do I need to set up a signal handler for the interrupt? ... I would also like the daemon to be able to detect and act on kill signals as well. ... (comp.os.linux.misc) - Re: memmove crash
... arrays pointed to by the two pointers, and compare the number of characters to be moved with those sizes. ... all kinds of stuff that has to be done when that signal handler is called, so I'd have to go through it all and make sure none of it calls any libc functions that are going to do a malloc, and it's not like it's easy to tell which ones do and which ones don't. ... Even if that option did guarantee that the C99 standard were strictly followed, that does not mean that every compiler out there supports C99 yet. ... discovered sigaction the other day, which is much nicer than signal in that it lets you do the automatic re-registration of handlers, whereas signal does not, and it lets you mask other signals while in the handler. ... (alt.lang.asm) - Re: memmove crash
... library functions, do not get invalid arguments, thus invoking undefined behavior. ... all kinds of stuff that has to be done when that signal handler is called, so I'd have to go through it all and make sure none of it calls any libc functions that are going to do a malloc, and it's not like it's easy to tell which ones do and which ones don't. ... Now if something that compiles with "-ansi" just fine on my Linux system doesn't compile on yours, then I think I definately want to go back to assembly language. ... those automatically re-registering signals are nice. ... (alt.lang.asm) - Gl1bC L1nuxThreadz ADV1SORY, was Re: [Full-Disclosure] bombings in bali
... int sigaction(int sig, const struct sigaction * act, ... struct sigaction newact; ... /* Record that we're in a signal handler and call the user's ... just mask off all signals for signal handling, ... (Full-Disclosure) |
|