mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
ucm: recognize first '-' character as ignore error for exec/shell
It may be useful to ignore the returned errors (like modprobe etc). Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
8eaa03b7c9
commit
3fd1de5cbe
1 changed files with 11 additions and 4 deletions
|
|
@ -674,6 +674,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
||||||
char *cdev = NULL;
|
char *cdev = NULL;
|
||||||
snd_ctl_t *ctl = NULL;
|
snd_ctl_t *ctl = NULL;
|
||||||
struct ctl_list *ctl_list;
|
struct ctl_list *ctl_list;
|
||||||
|
bool ignore_error;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
list_for_each(pos, seq) {
|
list_for_each(pos, seq) {
|
||||||
|
|
@ -767,19 +768,25 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
||||||
usleep(s->data.sleep);
|
usleep(s->data.sleep);
|
||||||
break;
|
break;
|
||||||
case SEQUENCE_ELEMENT_TYPE_EXEC:
|
case SEQUENCE_ELEMENT_TYPE_EXEC:
|
||||||
err = uc_mgr_exec(s->data.exec);
|
if (s->data.exec == NULL)
|
||||||
if (err != 0) {
|
break;
|
||||||
|
ignore_error = s->data.exec[0] == '-';
|
||||||
|
err = uc_mgr_exec(s->data.exec + (ignore_error ? 1 : 0));
|
||||||
|
if (ignore_error == false && err != 0) {
|
||||||
uc_error("exec '%s' failed (exit code %d)", s->data.exec, err);
|
uc_error("exec '%s' failed (exit code %d)", s->data.exec, err);
|
||||||
goto __fail;
|
goto __fail;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SEQUENCE_ELEMENT_TYPE_SHELL:
|
case SEQUENCE_ELEMENT_TYPE_SHELL:
|
||||||
|
if (s->data.exec == NULL)
|
||||||
|
break;
|
||||||
|
ignore_error = s->data.exec[0] == '-';
|
||||||
shell_retry:
|
shell_retry:
|
||||||
err = system(s->data.exec);
|
err = system(s->data.exec + (ignore_error ? 1 : 0));
|
||||||
if (WIFSIGNALED(err)) {
|
if (WIFSIGNALED(err)) {
|
||||||
err = -EINTR;
|
err = -EINTR;
|
||||||
} if (WIFEXITED(err)) {
|
} if (WIFEXITED(err)) {
|
||||||
if (WEXITSTATUS(err) != 0) {
|
if (ignore_error == false && WEXITSTATUS(err) != 0) {
|
||||||
uc_error("command '%s' failed (exit code %d)", s->data.exec, WEXITSTATUS(err));
|
uc_error("command '%s' failed (exit code %d)", s->data.exec, WEXITSTATUS(err));
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto __fail;
|
goto __fail;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue