[CRIU] [PATCHv2 4/5] service: don't leak a client socket if fork failed

Ruslan Kuprieiev kupruser at gmail.com
Fri Sep 20 18:19:29 EDT 2013


On 09/19/2013 02:37 PM, Andrey Vagin wrote:
> Cc: Ruslan Kuprieiev<kupruser at gmail.com>
> Signed-off-by: Andrey Vagin<avagin at openvz.org>
Original-patch-by: Andrey Vagin <avagin at openvz.org>
Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
-------------- next part --------------
diff --git a/cr-service.c b/cr-service.c
index 2891f33..f4589e7 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -288,12 +288,11 @@ int cr_service(bool daemon_mode)
 		pr_info("Connected.\n");
 
 		switch (child_pid = fork()) {
-		case -1:
-			pr_perror("Can't fork a child.");
-			continue;
-
 		case 0:
 			exit(cr_service_work());
+		case -1:
+			pr_perror("Can't fork a child.");
+			/* fall through */
 		default:
 			close(cr_service_client->sk_fd);
 		}



More information about the CRIU mailing list