[systemd-devel] [PATCH v2] udev: Allow detection of udevadm settle timeout

Nir Soffer nirsof at gmail.com
Sat Apr 18 15:33:32 PDT 2015


When udevadm settle times out, it exits with exit code 1. This make it
impossible for users to detect a timeout and handle real errors.  Now we
use exit code 3 on timeouts.
---
 src/udev/udevadm-settle.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index 2c84ada..114951c 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -29,6 +29,8 @@
 #include "udev.h"
 #include "util.h"
 
+#define EXIT_TIMEOUT 3
+
 static void help(void) {
         printf("%s settle OPTIONS\n\n"
                "Wait for pending udev events.\n\n"
@@ -142,8 +144,10 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
                         break;
                 }
 
-                if (timeout > 0 && now(CLOCK_MONOTONIC) >= deadline)
+                if (timeout > 0 && now(CLOCK_MONOTONIC) >= deadline) {
+                        rc = EXIT_TIMEOUT;
                         break;
+                }
 
                 /* wake up when queue is empty */
                 if (poll(pfd, 1, MSEC_PER_SEC) > 0 && pfd[0].revents & POLLIN)
-- 
1.9.3



More information about the systemd-devel mailing list