aboutsummaryrefslogtreecommitdiffstats
path: root/alarm.c
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2011-10-24 01:30:23 +0100
committerJonathan McCrohan <jmccrohan@gmail.com>2011-10-24 01:30:23 +0100
commit8adfff8b2419a0f79e85ba6884e507e787a313da (patch)
tree3e360dd9b0c2d238520b16718218045df4872bf6 /alarm.c
parent2643a5dc67dc6945ce8e0a3962818b16a240f0b5 (diff)
downloadverteco-8adfff8b2419a0f79e85ba6884e507e787a313da.tar.gz
Timer working. MAC address in string variable.
Diffstat (limited to '')
-rw-r--r--alarm.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/alarm.c b/alarm.c
new file mode 100644
index 0000000..a0bfa35
--- /dev/null
+++ b/alarm.c
@@ -0,0 +1,29 @@
+#include <signal.h>
+#include <stdio.h>
+#include <sys/select.h>
+#include <unistd.h>
+#include <time.h>
+
+volatile unsigned int variable = 0;
+volatile unsigned int print_variable = 0;
+
+void alarm_handler(int signum)
+{
+ alarm(60);
+}
+
+int main()
+{
+ signal(SIGALRM, alarm_handler);
+ alarm(1);
+
+ for (;;)
+ {
+ select(0, NULL, NULL, NULL, NULL);
+ time_t t = time(NULL);
+ struct tm tm = *localtime(&t);
+ printf("%d-%d-%d %d:%d:%d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
+
+ }
+}
+