Is it possible in C / C ++ on Linux to get information when the specified date / time is reached?

Is it possible to use standard C ++ on Linux to get information when the specified time / time is reached by the system time (unless, of course, my process is completed)?

I could just set the timer to the time I need to wait, but what happens if the user changes the system time? Can I get information from the system that the user has changed the system time to reset my timers?

+3
source share
4 answers

The Linux kernel has such system calls, although they are not integrated into the libc API. You can create a timer, get the file descriptor for it from the kernel, and make a call to select or epoll in the descriptor, which will be notified when the timer fires.

The man page for him: http://www.kernel.org/doc/man-pages/online/pages/man2/timerfd_create.2.html

+4
source

, , , . : , /, , , . , , , . , , .

+1

. "at" (man at)

, , , 14:35.

at 14:35
warning: commands will be executed using /bin/sh
at> mail -s "It is 2:35 PM" dbadmin < /dev/null
at><EOT> # After CTRL/D pressed.
job 9 at Tue May  8 14:35:00 2012
+1

sleep (difftime-1); 

Then you could control whether the time was reset, but in this way you could only correct the time to the future - if the time was delayed, you would miss the event.

-1
source

All Articles