summaryrefslogtreecommitdiff
path: root/src/udev/udev-event.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/udev/udev-event.c')
-rw-r--r--src/udev/udev-event.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 8d17c5e1e3..5516a792eb 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -30,7 +30,7 @@
#include <sys/wait.h>
#include <sys/signalfd.h>
-#include "rtnl-util.h"
+#include "netlink-util.h"
#include "event-util.h"
#include "formats-util.h"
#include "process-util.h"
@@ -42,6 +42,7 @@ typedef struct Spawn {
pid_t pid;
usec_t timeout_warn;
usec_t timeout;
+ bool accept_failure;
} Spawn;
struct udev_event *udev_event_new(struct udev_device *dev) {
@@ -62,7 +63,7 @@ struct udev_event *udev_event_new(struct udev_device *dev) {
void udev_event_unref(struct udev_event *event) {
if (event == NULL)
return;
- sd_rtnl_unref(event->rtnl);
+ sd_netlink_unref(event->rtnl);
udev_list_cleanup(&event->run_list);
udev_list_cleanup(&event->seclabel_list);
free(event->program_result);
@@ -583,23 +584,24 @@ static int on_spawn_sigchld(sd_event_source *s, const siginfo_t *si, void *userd
switch (si->si_code) {
case CLD_EXITED:
- if (si->si_status != 0)
- log_warning("process '%s' failed with exit code %i.", spawn->cmd, si->si_status);
- else {
- log_debug("process '%s' succeeded.", spawn->cmd);
+ if (si->si_status == 0) {
+ log_debug("Process '%s' succeeded.", spawn->cmd);
sd_event_exit(sd_event_source_get_event(s), 0);
return 1;
- }
+ } else if (spawn->accept_failure)
+ log_debug("Process '%s' failed with exit code %i.", spawn->cmd, si->si_status);
+ else
+ log_warning("Process '%s' failed with exit code %i.", spawn->cmd, si->si_status);
break;
case CLD_KILLED:
case CLD_DUMPED:
- log_warning("process '%s' terminated by signal %s.", spawn->cmd, signal_to_string(si->si_status));
+ log_warning("Process '%s' terminated by signal %s.", spawn->cmd, signal_to_string(si->si_status));
break;
default:
- log_error("process '%s' failed due to unknown reason.", spawn->cmd);
+ log_error("Process '%s' failed due to unknown reason.", spawn->cmd);
}
sd_event_exit(sd_event_source_get_event(s), -EIO);
@@ -610,10 +612,12 @@ static int on_spawn_sigchld(sd_event_source *s, const siginfo_t *si, void *userd
static int spawn_wait(struct udev_event *event,
usec_t timeout_usec,
usec_t timeout_warn_usec,
- const char *cmd, pid_t pid) {
+ const char *cmd, pid_t pid,
+ bool accept_failure) {
Spawn spawn = {
.cmd = cmd,
.pid = pid,
+ .accept_failure = accept_failure,
};
_cleanup_event_unref_ sd_event *e = NULL;
int r, ret;
@@ -698,6 +702,7 @@ out:
int udev_event_spawn(struct udev_event *event,
usec_t timeout_usec,
usec_t timeout_warn_usec,
+ bool accept_failure,
const char *cmd, char **envp,
char *result, size_t ressize) {
int outpipe[2] = {-1, -1};
@@ -773,7 +778,7 @@ int udev_event_spawn(struct udev_event *event,
outpipe[READ_END], errpipe[READ_END],
result, ressize);
- err = spawn_wait(event, timeout_usec, timeout_warn_usec, cmd, pid);
+ err = spawn_wait(event, timeout_usec, timeout_warn_usec, cmd, pid, accept_failure);
}
out:
@@ -930,7 +935,7 @@ void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec, usec_
udev_event_apply_format(event, cmd, program, sizeof(program));
envp = udev_device_get_properties_envp(event->dev);
- udev_event_spawn(event, timeout_usec, timeout_warn_usec, program, envp, NULL, 0);
+ udev_event_spawn(event, timeout_usec, timeout_warn_usec, false, program, envp, NULL, 0);
}
}
}