Ver Fonte

- kill all children on error

Andrei Pelinescu-Onciul há 23 anos atrás
pai
commit
3db079b509
1 ficheiros alterados com 13 adições e 4 exclusões
  1. 13 4
      main.c

+ 13 - 4
main.c

@@ -384,7 +384,7 @@ void handle_sigs()
 			if (sig_flag==SIGINT)
 			if (sig_flag==SIGINT)
 				DBG("INT received, program terminates\n");
 				DBG("INT received, program terminates\n");
 			else if (sig_flag==SIGPIPE)
 			else if (sig_flag==SIGPIPE)
-				DBG("SIGPIPE rreceived, program terminates\n");
+				DBG("SIGPIPE received, program terminates\n");
 			else
 			else
 				DBG("SIGTERM received, program terminates\n");
 				DBG("SIGTERM received, program terminates\n");
 				
 				
@@ -836,8 +836,13 @@ int main(int argc, char** argv)
 	struct utsname myname;
 	struct utsname myname;
 	char *options;
 	char *options;
 	char port_no_str[MAX_PORT_LEN];
 	char port_no_str[MAX_PORT_LEN];
-	int port_no_str_len=0;
+	int port_no_str_len;
+	int ret;
 
 
+	/*init*/
+	port_no_str_len=0;
+	ret=-1;
+	
 	/* added by jku: add exit handler */
 	/* added by jku: add exit handler */
 	if (signal(SIGINT, sig_usr) == SIG_ERR ) {
 	if (signal(SIGINT, sig_usr) == SIG_ERR ) {
 		DPrint("ERROR: no SIGINT signal handler can be installed\n");
 		DPrint("ERROR: no SIGINT signal handler can be installed\n");
@@ -1280,10 +1285,14 @@ int main(int argc, char** argv)
 	if (init_stats(  dont_fork ? 1 : children_no  )==-1) goto error;
 	if (init_stats(  dont_fork ? 1 : children_no  )==-1) goto error;
 #endif
 #endif
 	
 	
-	return main_loop();
-
+	ret=main_loop();
+	/*kill everything*/
+	kill(0, SIGTERM);
+	return ret;
 
 
 error:
 error:
+	/*kill everything*/
+	kill(0, SIGTERM);
 	return -1;
 	return -1;
 
 
 }
 }