diff --git a/helpers.c b/helpers.c index 04bd2cb5..ce9c2326 100644 --- a/helpers.c +++ b/helpers.c @@ -617,11 +617,17 @@ int run_parts(char *dir, ...) qsort(ent, num, sizeof(char *), cmp); for (i = 0; i < num; i++) { + int j = 0, status; pid_t pid = 0; - int status; - args[0] = ent[i]; - args[1] = NULL; + args[j++] = ent[i]; + /* Check if Sservice or Kservice notation is used */ + if (ent[i][0] == 'S' && isdigit(ent[i][1])) { + args[j++] = "start"; + } else if (ent[i][0] == 'K' && isdigit(ent[i][1])) { + args[j++] = "stop"; + } + args[j++] = NULL; pid = fork(); if (!pid) { diff --git a/plugins/alsa-utils.c b/plugins/alsa-utils.c index cf43e263..9100521a 100644 --- a/plugins/alsa-utils.c +++ b/plugins/alsa-utils.c @@ -27,14 +27,14 @@ static void save(void *UNUSED(arg)) { - _d("Saving system clock to RTC ..."); - run_interactive("/usr/sbin/alsactl store > /dev/null 2>&1", "Saving sound settings"); + _d("Saving sound settings ..."); + run_interactive("/usr/sbin/alsactl -g store", "Saving sound settings"); } static void restore(void *UNUSED(arg)) { - _d("Restoring system clock from RTC ..."); - run_interactive("/usr/sbin/alsactl restore > /dev/null 2>&1", "Restoring sound settings"); + _d("Restoring sound settings ..."); + run_interactive("/usr/sbin/alsactl -g restore", "Restoring sound settings"); } static plugin_t plugin = { diff --git a/svc.c b/svc.c index 63431bfd..92a4ee3d 100644 --- a/svc.c +++ b/svc.c @@ -273,6 +273,20 @@ int svc_start(svc_t *svc) sigset_t nmask, omask; char *args[MAX_NUM_SVC_ARGS]; + if (!svc) + return 0; + + /* Don't try and start service if it doesn't exist. */ + if (!fexist(svc->cmd)) { + char msg[80]; + + snprintf(msg, sizeof(msg), "Service %s does not exist!", svc->cmd); + print_desc("", msg); + print_result(1); + + return 0; + } + /* Ignore if finit is SIGSTOP'ed */ if (is_norespawn()) return 0; @@ -329,7 +343,10 @@ int svc_start(svc_t *svc) _e("%starting %s: %s", respawn ? "Res" : "S", svc->cmd, buf); } - execvp(svc->cmd, args); + /* XXX: Maybe change to use execve() to be able to launch scripts? */ + execv(svc->cmd, args); + + /* Only reach this point if exec() fails. */ exit(0); } svc->pid = pid;