summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog3
-rw-r--r--utils/start-stop-daemon.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 92a9a078d..5dfe746fd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -58,6 +58,9 @@ dpkg (1.18.0) UNRELEASED; urgency=low
original. Closes: #773718
* Do not leak kvm descriptors in start-stop-daemon on GNU/kFreeBSD systems.
Based on a patch by Jeff Epler <jepler@unpythonic.net>. Closes: #779467
+ * Switch start-stop-daemon to use a monotonic clock if available. This
+ makes the timeout checks resilient to abrupt system clock changes.
+ Suggested by Jose M Calhariz <jose.calhariz@hds.com>. Closes: #783014
* Perl modules:
- Rename and deprecate Dpkg::Gettext _g function with new g_.
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index a7e96c970..ce95fd1d1 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -73,6 +73,7 @@
#include <assert.h>
#include <errno.h>
#include <limits.h>
+#include <time.h>
#include <fcntl.h>
#include <dirent.h>
#include <ctype.h>
@@ -309,6 +310,11 @@ xstrdup(const char *str)
static void
timespec_gettime(struct timespec *ts)
{
+#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && \
+ defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK > 0
+ if (clock_gettime(CLOCK_MONOTONIC, ts) < 0)
+ fatal("clock_gettime failed");
+#else
struct timeval tv;
if (gettimeofday(&tv, NULL) != 0)
@@ -316,6 +322,7 @@ timespec_gettime(struct timespec *ts)
ts->tv_sec = tv.tv_sec;
ts->tv_nsec = tv.tv_usec * NANOSEC_IN_MICROSEC;
+#endif
}
#define timespec_cmp(a, b, OP) \