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

Andrey Vagin avagin at openvz.org
Thu Sep 19 06:37:47 EDT 2013


Cc: Ruslan Kuprieiev <kupruser at gmail.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-service.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/cr-service.c b/cr-service.c
index ee0f849..514bd44 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -279,12 +279,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(msg));
+		case -1:
+			pr_perror("Can't fork a child.");
+			/* fall through */
 		default:
 			close(cr_service_client->sk_fd);
 		}
-- 
1.8.3.1



More information about the CRIU mailing list