summary refs log tree commit diff
path: root/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--daemon.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/daemon.c b/daemon.c
index 0e15c12..969675f 100644
--- a/daemon.c
+++ b/daemon.c
@@ -126,6 +126,7 @@ static void parseControl(char *command) {
 		return;
 	}
 
+	bool drop = false;
 	Action *fn = NULL;
 	int signal = 0;
 	if (!strcmp(action, "start")) {
@@ -136,6 +137,8 @@ static void parseControl(char *command) {
 		fn = serviceRestart;
 	} else if (!strcmp(action, "status")) {
 		fn = serviceStatus;
+	} else if (!strcmp(action, "drop")) {
+		drop = true;
 	} else {
 		for (int i = 1; i < NSIG; ++i) {
 			if (strcasecmp(action, sys_signame[i])) continue;
@@ -143,7 +146,7 @@ static void parseControl(char *command) {
 			break;
 		}
 	}
-	if (!fn && !signal) {
+	if (!drop && !fn && !signal) {
 		syslog(LOG_NOTICE, "unknown action or signal %s", action);
 		return;
 	}
@@ -151,10 +154,12 @@ static void parseControl(char *command) {
 	while (command) {
 		bool found = false;
 		char *pattern = strsep(&command, WS);
-		for (size_t i = 0; i < services.len; ++i) {
+		for (size_t i = services.len - 1; i < services.len; --i) {
 			struct Service *service = &services.ptr[i];
 			if (fnmatch(pattern, service->name, 0)) continue;
-			if (signal) {
+			if (drop) {
+				serviceDrop(i);
+			} else if (signal) {
 				serviceSignal(service, signal);
 			} else {
 				fn(service);