Slightly simplify and document script executing

This commit is contained in:
fwsmit 2021-01-21 16:48:20 +01:00
parent 52134ab8ce
commit bc3de38aa7

View File

@ -129,6 +129,7 @@ void notification_run_script(struct notification *n)
int status; int status;
waitpid(pid1, &status, 0); waitpid(pid1, &status, 0);
} else { } else {
// second fork to prevent zombie processes
int pid2 = fork(); int pid2 = fork();
if (pid2) { if (pid2) {
exit(0); exit(0);
@ -153,7 +154,7 @@ void notification_run_script(struct notification *n)
safe_setenv("DUNST_TIMESTAMP", n_timestamp_str); safe_setenv("DUNST_TIMESTAMP", n_timestamp_str);
safe_setenv("DUNST_STACK_TAG", n->stack_tag); safe_setenv("DUNST_STACK_TAG", n->stack_tag);
int ret = execlp(script, execlp(script,
script, script,
appname, appname,
summary, summary,
@ -161,10 +162,9 @@ void notification_run_script(struct notification *n)
icon, icon,
urgency, urgency,
(char *)NULL); (char *)NULL);
if (ret != 0) {
LOG_W("Unable to run script %s: %s", n->scripts[i], strerror(errno)); LOG_W("Unable to run script %s: %s", n->scripts[i], strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
}
} }
} }
} }