Browse code

kill fifo command introduced

Jiri Kuthan authored on 27/02/2003 20:20:13
Showing 2 changed files
... ...
@@ -684,6 +684,17 @@ static int uptime_fifo_cmd( FILE *stream, char *response_file )
684 684
 	return 1;
685 685
 }
686 686
 
687
+static int kill_fifo_cmd( FILE *stream, char *response_file )
688
+{
689
+	if (response_file==0 || *response_file==0 ) { 
690
+		LOG(L_ERR, "ERROR: uptime_fifo_cmd: null file\n");
691
+		return -1;
692
+	}
693
+	fifo_reply(response_file, "200 killing now..." );
694
+	kill(0, SIGTERM);
695
+	return 1;
696
+}
697
+
687 698
 static int which_fifo_cmd(FILE *stream, char *response_file )
688 699
 {
689 700
 	FILE *reply_pipe;
... ...
@@ -765,5 +776,9 @@ int register_core_fifo()
765 765
 		LOG(L_CRIT, "unable to register '%s' FIFO cmd\n", FIFO_PS);
766 766
 		return -1;
767 767
 	}
768
+	if (register_fifo_cmd(kill_fifo_cmd, FIFO_KILL, 0)<0) {
769
+		LOG(L_CRIT, "unable to register '%s' FIFO cmd\n", FIFO_KILL);
770
+		return -1;
771
+	}
768 772
 	return 1;
769 773
 }
... ...
@@ -49,6 +49,8 @@
49 49
 #define FIFO_ARG "arg"
50 50
 /* print server's working directory */
51 51
 #define FIFO_PWD "pwd"
52
+/* kill the server */
53
+#define FIFO_KILL "kill"
52 54
 
53 55
 #define MAX_CTIME_LEN 128
54 56