summary refs log tree commit diff
path: root/service.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--service.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/service.c b/service.c
index e7cfe2f..63a647c 100644
--- a/service.c
+++ b/service.c
@@ -34,6 +34,11 @@
 
 #include "daemon.h"
 
+enum {
+	ExitNotFound = 127,
+	ExitNoExec   = 126,
+};
+
 const char *serviceDir = "/";
 uid_t serviceUID;
 gid_t serviceGID;
@@ -173,13 +178,13 @@ void serviceStart(struct Service *service) {
 	dup2(service->errPipe[1], STDERR_FILENO);
 
 	int error = chdir(serviceDir);
-	if (error) err(StopExit, "%s", serviceDir);
+	if (error) err(ExitNoExec, "%s", serviceDir);
 
 	error = setgid(serviceGID);
-	if (error) err(StopExit, "setgid");
+	if (error) err(ExitNoExec, "setgid");
 
 	error = setuid(serviceUID);
-	if (error) err(StopExit, "setuid");
+	if (error) err(ExitNoExec, "setuid");
 
 	size_t len = 0;
 	char command[ARG_MAX];
@@ -197,7 +202,7 @@ void serviceStart(struct Service *service) {
 		_PATH_BSHELL, "-c", command, service->name, NULL,
 		serviceEnviron
 	);
-	err(StopExit, "%s", _PATH_BSHELL);
+	err(ExitNotFound, "%s", _PATH_BSHELL);
 }
 
 void serviceSignal(struct Service *service, int signal) {
@@ -266,7 +271,11 @@ void serviceReap(pid_t pid, int status) {
 	service->state = Stop;
 	if (WIFEXITED(status)) {
 		int exit = WEXITSTATUS(status);
-		if (exit == StopExit || setTest(&stopExits, exit)) {
+		if (
+			exit == ExitNotFound ||
+			exit == ExitNoExec ||
+			setTest(&stopExits, exit)
+		) {
 			service->intent = Stop;
 		}
 		if (exit) {