summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/udev/udevadm-settle.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index 0d3025ed16..2c84ada0b1 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -49,6 +49,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
{ "quiet", no_argument, NULL, 'q' }, /* removed */
{}
};
+ usec_t deadline;
const char *exists = NULL;
unsigned int timeout = 120;
struct pollfd pfd[1] = { {.fd = -1}, };
@@ -98,6 +99,8 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
return EXIT_FAILURE;
}
+ deadline = now(CLOCK_MONOTONIC) + timeout * USEC_PER_SEC;
+
/* guarantee that the udev daemon isn't pre-processing */
if (getuid() == 0) {
struct udev_ctrl *uctrl;
@@ -139,6 +142,9 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
break;
}
+ if (timeout > 0 && now(CLOCK_MONOTONIC) >= deadline)
+ break;
+
/* wake up when queue is empty */
if (poll(pfd, 1, MSEC_PER_SEC) > 0 && pfd[0].revents & POLLIN)
udev_queue_flush(queue);