|
|
4e3b3d |
diff -ur -x configure at-3.1.13.orig/atd.c at-3.1.13/atd.c
|
|
|
4e3b3d |
--- at-3.1.13.orig/atd.c 2011-11-16 11:30:22.424764253 -0500
|
|
|
4e3b3d |
+++ at-3.1.13/atd.c 2011-11-16 16:41:12.102831656 -0500
|
|
|
4e3b3d |
@@ -815,6 +815,54 @@
|
|
|
4e3b3d |
return next_job;
|
|
|
4e3b3d |
}
|
|
|
4e3b3d |
|
|
|
4e3b3d |
+#ifdef HAVE_CLOCK_GETTIME
|
|
|
4e3b3d |
+timer_t timer;
|
|
|
4e3b3d |
+struct itimerspec timeout;
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
+void timer_setup()
|
|
|
4e3b3d |
+{
|
|
|
4e3b3d |
+ struct sigevent sev;
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
+ sev.sigev_notify = SIGEV_SIGNAL;
|
|
|
4e3b3d |
+ sev.sigev_signo = SIGHUP;
|
|
|
4e3b3d |
+ sev.sigev_value.sival_ptr = &timer;
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
+ memset(&timeout, 0, sizeof(timeout));
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
+ if (timer_create(CLOCK_REALTIME, &sev, &timer) < 0)
|
|
|
4e3b3d |
+ pabort("unable to create timer");
|
|
|
4e3b3d |
+}
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
+time_t atd_gettime()
|
|
|
4e3b3d |
+{
|
|
|
4e3b3d |
+ struct timespec curtime;
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
+ clock_gettime(CLOCK_REALTIME, &curtime);
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
+ return curtime.tv_sec;
|
|
|
4e3b3d |
+}
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
+void atd_setalarm(time_t next)
|
|
|
4e3b3d |
+{
|
|
|
4e3b3d |
+ timeout.it_value.tv_sec = next;
|
|
|
4e3b3d |
+ timer_settime(timer, TIMER_ABSTIME, &timeout, NULL);
|
|
|
4e3b3d |
+ pause();
|
|
|
4e3b3d |
+}
|
|
|
4e3b3d |
+#else
|
|
|
4e3b3d |
+void timer_setup()
|
|
|
4e3b3d |
+{
|
|
|
4e3b3d |
+}
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
+time_t atd_gettime()
|
|
|
4e3b3d |
+{
|
|
|
4e3b3d |
+ return time(NULL);
|
|
|
4e3b3d |
+}
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
+void atd_setalarm(time_t next)
|
|
|
4e3b3d |
+{
|
|
|
4e3b3d |
+ sleep(next - atd_gettime());
|
|
|
4e3b3d |
+}
|
|
|
4e3b3d |
+#endif
|
|
|
4e3b3d |
/* Global functions */
|
|
|
4e3b3d |
|
|
|
4e3b3d |
int
|
|
|
4e3b3d |
@@ -835,7 +883,6 @@
|
|
|
4e3b3d |
struct sigaction act;
|
|
|
4e3b3d |
struct passwd *pwe;
|
|
|
4e3b3d |
struct group *ge;
|
|
|
4e3b3d |
-
|
|
|
4e3b3d |
#ifdef WITH_SELINUX
|
|
|
4e3b3d |
selinux_enabled=is_selinux_enabled();
|
|
|
4e3b3d |
#endif
|
|
|
4e3b3d |
@@ -912,7 +959,7 @@
|
|
|
4e3b3d |
sigaction(SIGCHLD, &act, NULL);
|
|
|
4e3b3d |
|
|
|
4e3b3d |
if (!run_as_daemon) {
|
|
|
4e3b3d |
- now = time(NULL);
|
|
|
4e3b3d |
+ now = atd_gettime();
|
|
|
4e3b3d |
run_loop();
|
|
|
4e3b3d |
exit(EXIT_SUCCESS);
|
|
|
4e3b3d |
}
|
|
|
4e3b3d |
@@ -935,13 +982,15 @@
|
|
|
4e3b3d |
act.sa_handler = set_term;
|
|
|
4e3b3d |
sigaction(SIGINT, &act, NULL);
|
|
|
4e3b3d |
|
|
|
4e3b3d |
+ timer_setup();
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
daemon_setup();
|
|
|
4e3b3d |
|
|
|
4e3b3d |
do {
|
|
|
4e3b3d |
- now = time(NULL);
|
|
|
4e3b3d |
+ now = atd_gettime();
|
|
|
4e3b3d |
next_invocation = run_loop();
|
|
|
4e3b3d |
if (next_invocation > now) {
|
|
|
4e3b3d |
- sleep(next_invocation - now);
|
|
|
4e3b3d |
+ atd_setalarm(next_invocation);
|
|
|
4e3b3d |
}
|
|
|
4e3b3d |
} while (!term_signal);
|
|
|
4e3b3d |
daemon_cleanup();
|
|
|
4e3b3d |
diff -ur -x configure at-3.1.13.orig/config.h.in at-3.1.13/config.h.in
|
|
|
4e3b3d |
--- at-3.1.13.orig/config.h.in 2011-11-16 11:30:22.424764253 -0500
|
|
|
4e3b3d |
+++ at-3.1.13/config.h.in 2011-11-16 16:32:44.485426754 -0500
|
|
|
4e3b3d |
@@ -38,6 +38,9 @@
|
|
|
4e3b3d |
/* Define to 1 if you have the `getloadavg' function. */
|
|
|
4e3b3d |
#undef HAVE_GETLOADAVG
|
|
|
4e3b3d |
|
|
|
4e3b3d |
+/* Define to 1 if you have the `clock_gettime' function. */
|
|
|
4e3b3d |
+#undef HAVE_TIMER_CREATE
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
/* Define to 1 if you have the <getopt.h> header file. */
|
|
|
4e3b3d |
#undef HAVE_GETOPT_H
|
|
|
4e3b3d |
|
|
|
4e3b3d |
diff -ur -x configure at-3.1.13.orig/configure.ac at-3.1.13/configure.ac
|
|
|
4e3b3d |
--- at-3.1.13.orig/configure.ac 2011-11-16 11:30:22.425764254 -0500
|
|
|
4e3b3d |
+++ at-3.1.13/configure.ac 2011-11-16 16:31:29.791561747 -0500
|
|
|
4e3b3d |
@@ -274,5 +274,9 @@
|
|
|
4e3b3d |
AC_SUBST(SELINUXLIB)
|
|
|
4e3b3d |
AC_SUBST(WITH_SELINUX)
|
|
|
4e3b3d |
|
|
|
4e3b3d |
+dnl check for POSIX timer functions
|
|
|
4e3b3d |
+AC_SEARCH_LIBS([timer_create],[rt])
|
|
|
4e3b3d |
+AC_CHECK_FUNCS([timer_create])
|
|
|
4e3b3d |
+
|
|
|
4e3b3d |
AC_CONFIG_FILES(Makefile atrun atd.8 atrun.8 at.1 at.allow.5 batch)
|
|
|
4e3b3d |
AC_OUTPUT
|