summaryrefslogtreecommitdiff
path: root/src/udev/udev-event.c
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2015-06-14 20:19:54 +0200
committerKay Sievers <kay@vrfy.org>2015-06-14 20:19:54 +0200
commit15daf6a834563fe5afc3143aaf41bd9a4adc24ed (patch)
treeb35cd45320829a07f1c8455aec4694ce2c92e1f5 /src/udev/udev-event.c
parent7258e9704f49f29dd6ef19657cbecc3ebbdeae01 (diff)
parent53318514cce4c129c9e8c97a5fba8ddbd09f1bb5 (diff)
Merge pull request #144 from teg/udev-spawn-log-less-2
udevd: event - don't log about failures of spawn processes when this …
Diffstat (limited to 'src/udev/udev-event.c')
-rw-r--r--src/udev/udev-event.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 7e16922c70..5516a792eb 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -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) {
@@ -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);
}
}
}