mirror of
https://github.com/systemd/systemd.git
synced 2024-11-05 15:21:37 +03:00
Merge pull request #144 from teg/udev-spawn-log-less-2
udevd: event - don't log about failures of spawn processes when this …
This commit is contained in:
commit
15daf6a834
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user