Re: Automatic notification to application based on system date and
- From: Jan Panteltje <pNaonStpealmtje@xxxxxxxxx>
- Date: Thu, 28 Sep 2006 18:03:09 GMT
On a sunny day (Thu, 28 Sep 2006 13:01:41 -0400) it happened Joe Beanfish
<joe@xxxxxxxxxx> wrote in <efgv5l$q5k@xxxxxxxxxxxxxxxxxxxxx>:
Josef Moellers wrote:
dadu wrote:
Hello guys,
I need OS support in my application to receive signal or event from OS
when I configure it for particular date and time. In short, I am
expecting OS notification in my application on particular date and
time. Can anybody please help me on, how to implement this on linux?
You might want to look at alarm(2).
Thank you. I was reading this thread and thought everyone lost their
mind suggesting polling, other programs signalling, cron, etc.
Well, you may be right with 'alarm()', but it requires you to first
find out the seconds in the future from your year, month, day, hour etc.
with time_t timelocal (struct tm *BROKENTIME) anytime you start up
your application.
So you fill in struct tm with your date, and then use timelocal() to
set a time_t value for alarm.
But if your program has any sort of polling loop you can just as well
poll with mktime() and friends, _ESPECIALLY_ if it uses alarm() to display
a clock!!
So, that is how I do it here:
http://panteltje.com/panteltje/satellite/xdipo-0.6.8.1.tgz
note the clock, and in an other couple TV applications, such a xcha.
These have a linked list with timers, ftp://panteltje.com/pub/xdipo2.jpg
So it all depends, this one needs to be running all the time, but so does yours.
I like the solution using 'at' mentioned here.
.
- References:
- Prev by Date: Re: Automatic notification to application based on system date and time (Monta-vista linux)
- Next by Date: agetty question
- Previous by thread: Re: Automatic notification to application based on system date and
- Next by thread: agetty question
- Index(es):
Relevant Pages
|