summaryrefslogtreecommitdiff
path: root/src/udev
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
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')
-rw-r--r--src/udev/udev-event.c25
-rw-r--r--src/udev/udev-rules.c4
-rw-r--r--src/udev/udev.h1
3 files changed, 18 insertions, 12 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);
}
}
}
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 7be9a2311a..8ebc061eb1 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -641,7 +641,7 @@ static int import_program_into_properties(struct udev_event *event,
int err;
envp = udev_device_get_properties_envp(dev);
- err = udev_event_spawn(event, timeout_usec, timeout_warn_usec, program, envp, result, sizeof(result));
+ err = udev_event_spawn(event, timeout_usec, timeout_warn_usec, true, program, envp, result, sizeof(result));
if (err < 0)
return err;
@@ -2131,7 +2131,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
rules_str(rules, rule->rule.filename_off),
rule->rule.filename_line);
- if (udev_event_spawn(event, timeout_usec, timeout_warn_usec, program, envp, result, sizeof(result)) < 0) {
+ if (udev_event_spawn(event, timeout_usec, timeout_warn_usec, true, program, envp, result, sizeof(result)) < 0) {
if (cur->key.op != OP_NOMATCH)
goto nomatch;
} else {
diff --git a/src/udev/udev.h b/src/udev/udev.h
index 59751b4c90..3dca72e499 100644
--- a/src/udev/udev.h
+++ b/src/udev/udev.h
@@ -84,6 +84,7 @@ int udev_event_apply_subsys_kernel(struct udev_event *event, const char *string,
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);
void udev_event_execute_rules(struct udev_event *event,