size_t result_len;
} Spawn;
-struct udev_event *udev_event_new(sd_device *dev, int exec_delay, sd_netlink *rtnl) {
+struct udev_event *udev_event_new(sd_device *dev, usec_t exec_delay_usec, sd_netlink *rtnl) {
struct udev_event *event;
assert(dev);
*event = (struct udev_event) {
.dev = sd_device_ref(dev),
.birth_usec = now(CLOCK_MONOTONIC),
- .exec_delay = exec_delay,
+ .exec_delay_usec = exec_delay_usec,
.rtnl = sd_netlink_ref(rtnl),
};
if (builtin_cmd >= 0 && builtin_cmd < _UDEV_BUILTIN_MAX)
udev_builtin_run(event->dev, builtin_cmd, command, false);
else {
- if (event->exec_delay > 0) {
+ if (event->exec_delay_usec > 0) {
log_debug("delay execution of '%s'", command);
- sleep(event->exec_delay);
+ (void) usleep(event->exec_delay_usec);
}
udev_event_spawn(event, timeout_usec, timeout_warn_usec, false, command, NULL, 0);
gid_t gid;
Hashmap *seclabel_list;
Hashmap *run_list;
- int exec_delay;
+ usec_t exec_delay_usec;
usec_t birth_usec;
sd_netlink *rtnl;
unsigned builtin_run;
int udev_rules_apply_static_dev_perms(struct udev_rules *rules);
/* udev-event.c */
-struct udev_event *udev_event_new(sd_device *dev, int exec_delay, sd_netlink *rtnl);
+struct udev_event *udev_event_new(sd_device *dev, usec_t exec_delay_usec, sd_netlink *rtnl);
struct udev_event *udev_event_free(struct udev_event *event);
ssize_t udev_event_apply_format(struct udev_event *event,
const char *src, char *dest, size_t size,
static int arg_daemonize = false;
static int arg_resolve_names = 1;
static unsigned arg_children_max = 0;
-static int arg_exec_delay = 0;
+static usec_t arg_exec_delay_usec = 0;
static usec_t arg_event_timeout_usec = 180 * USEC_PER_SEC;
static usec_t arg_event_timeout_warn_usec = 180 * USEC_PER_SEC / 3;
assert(dev);
log_debug("seq %llu running", udev_device_get_seqnum(dev));
- udev_event = udev_event_new(dev->device, arg_exec_delay, rtnl);
+ udev_event = udev_event_new(dev->device, arg_exec_delay_usec, rtnl);
if (!udev_event) {
r = -ENOMEM;
goto out;
if (proc_cmdline_value_missing(key, value))
return 0;
- r = safe_atoi(value, &arg_exec_delay);
+ r = parse_sec(value, &arg_exec_delay_usec);
} else if (startswith(key, "udev."))
log_warning("Unknown udev kernel command line option \"%s\"", key);
log_warning("Invalid --children-max ignored: %s", optarg);
break;
case 'e':
- r = safe_atoi(optarg, &arg_exec_delay);
+ r = parse_sec(optarg, &arg_exec_delay_usec);
if (r < 0)
- log_warning("Invalid --exec-delay ignored: %s", optarg);
+ log_warning_errno(r, "Failed to parse --exec-delay= value '%s', ignoring: %m", optarg);
break;
case 't':
r = safe_atou64(optarg, &arg_event_timeout_usec);