diff --git a/man/udevadm.xml b/man/udevadm.xml
index 44be7b3f894..e6d4a1b1081 100644
--- a/man/udevadm.xml
+++ b/man/udevadm.xml
@@ -419,6 +419,13 @@
same time.
+
+
+
+ Send a ping message to systemd-udevd and wait for the reply. This may be useful to check that
+ systemd-udevd daemon is running.
+
+
seconds
diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c
index 4cd3eba1bc5..7cfc4c929d1 100644
--- a/src/udev/udevadm-control.c
+++ b/src/udev/udevadm-control.c
@@ -40,6 +40,7 @@ static int help(void) {
" -R --reload Reload rules and databases\n"
" -p --property=KEY=VALUE Set a global property for all events\n"
" -m --children-max=N Maximum number of children\n"
+ " --ping Wait for udev to respond to a ping message\n"
" -t --timeout=SECONDS Maximum time to block for a reply\n"
, program_invocation_short_name);
@@ -51,19 +52,24 @@ int control_main(int argc, char *argv[], void *userdata) {
usec_t timeout = 60 * USEC_PER_SEC;
int c, r;
+ enum {
+ ARG_PING = 0x100,
+ };
+
static const struct option options[] = {
- { "exit", no_argument, NULL, 'e' },
- { "log-priority", required_argument, NULL, 'l' },
- { "stop-exec-queue", no_argument, NULL, 's' },
- { "start-exec-queue", no_argument, NULL, 'S' },
- { "reload", no_argument, NULL, 'R' },
- { "reload-rules", no_argument, NULL, 'R' }, /* alias for -R */
- { "property", required_argument, NULL, 'p' },
- { "env", required_argument, NULL, 'p' }, /* alias for -p */
- { "children-max", required_argument, NULL, 'm' },
- { "timeout", required_argument, NULL, 't' },
- { "version", no_argument, NULL, 'V' },
- { "help", no_argument, NULL, 'h' },
+ { "exit", no_argument, NULL, 'e' },
+ { "log-priority", required_argument, NULL, 'l' },
+ { "stop-exec-queue", no_argument, NULL, 's' },
+ { "start-exec-queue", no_argument, NULL, 'S' },
+ { "reload", no_argument, NULL, 'R' },
+ { "reload-rules", no_argument, NULL, 'R' }, /* alias for -R */
+ { "property", required_argument, NULL, 'p' },
+ { "env", required_argument, NULL, 'p' }, /* alias for -p */
+ { "children-max", required_argument, NULL, 'm' },
+ { "ping", no_argument, NULL, ARG_PING },
+ { "timeout", required_argument, NULL, 't' },
+ { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
{}
};
@@ -135,6 +141,11 @@ int control_main(int argc, char *argv[], void *userdata) {
return r;
break;
}
+ case ARG_PING:
+ r = udev_ctrl_send_ping(uctrl, timeout);
+ if (r < 0)
+ return log_error_errno(r, "Failed to connect to udev daemon: %m");
+ break;
case 't':
r = parse_sec(optarg, &timeout);
if (r < 0)