[CRIU] [PATCH 2/3] crtools: fix exit code for page-server

Andrei Vagin avagin at openvz.org
Thu Nov 17 12:10:50 PST 2016


From: Andrei Vagin <avagin at virtuozzo.com>

cr_page_server() returns pid, if it is executed as a daemon
otherwise it returns an error code.

crtools returns 0 only if cr_page_server() returns a positive value,
what is obviously wrong.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/crtools.c   | 2 +-
 criu/page-xfer.c | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/criu/crtools.c b/criu/crtools.c
index eedb8c0..3dc347a 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -776,7 +776,7 @@ int main(int argc, char *argv[], char *envp[])
 #endif
 
 	if (!strcmp(argv[optind], "page-server"))
-		return cr_page_server(opts.daemon_mode, -1) > 0 ? 0 : 1;
+		return cr_page_server(opts.daemon_mode, -1) != 0;
 
 	if (!strcmp(argv[optind], "service"))
 		return cr_service(opts.daemon_mode);
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 7f1d0f7..e6bc8f6 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -810,7 +810,9 @@ int cr_page_server(bool daemon_mode, int cfd)
 		return -1;
 no_server:
 	ret = run_tcp_server(daemon_mode, &ask, cfd, sk);
-	if (ret != 0)
+	if (ret > 0)
+		return 0;
+	if (ret < 0)
 		return ret;
 
 	if (ask >= 0)
-- 
2.7.4



More information about the CRIU mailing list