|
Radostin Stoyanov |
46abdd7 |
From 983464ffad11a0f8c5656492f3c342139acd2527 Mon Sep 17 00:00:00 2001
|
|
Radostin Stoyanov |
46abdd7 |
From: Liu Hua <weldonliu@tencent.com>
|
|
Radostin Stoyanov |
46abdd7 |
Date: Thu, 4 Nov 2021 10:04:22 +0800
|
|
Radostin Stoyanov |
46abdd7 |
Subject: [PATCH 052/120] crtools: ignore SIGPIPE in swrk mode
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
Criu ignores SIGPIPE in most cases except swrk mode. And in the
|
|
Radostin Stoyanov |
46abdd7 |
following situtation criu get killed by SIGPIPE and have no chance
|
|
Radostin Stoyanov |
46abdd7 |
to do cleanup: Connection to page server is lost when we do disk-less
|
|
Radostin Stoyanov |
46abdd7 |
migration, criu send PS_IOV_FLUSH via a broken connction in
|
|
Radostin Stoyanov |
46abdd7 |
disconnect_from_page_server.
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
This patch let criu ignore SIGPIPE in all paths .
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
Signed-off-by: Liu Hua <weldonliu@tencent.com>
|
|
Radostin Stoyanov |
46abdd7 |
---
|
|
Radostin Stoyanov |
46abdd7 |
criu/crtools.c | 33 ++++++++++++++++++---------------
|
|
Radostin Stoyanov |
46abdd7 |
1 file changed, 18 insertions(+), 15 deletions(-)
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
diff --git a/criu/crtools.c b/criu/crtools.c
|
|
Radostin Stoyanov |
46abdd7 |
index 6a75cd1ea..81c0aa963 100644
|
|
Radostin Stoyanov |
46abdd7 |
--- a/criu/crtools.c
|
|
Radostin Stoyanov |
46abdd7 |
+++ b/criu/crtools.c
|
|
Radostin Stoyanov |
46abdd7 |
@@ -106,6 +106,24 @@ int main(int argc, char *argv[], char *envp[])
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
log_set_loglevel(opts.log_level);
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
+ /*
|
|
Radostin Stoyanov |
46abdd7 |
+ * There kernel might send us lethal signals in the following cases:
|
|
Radostin Stoyanov |
46abdd7 |
+ * 1) Writing a pipe which reader has disappeared.
|
|
Radostin Stoyanov |
46abdd7 |
+ * 2) Writing to a socket of type SOCK_STREAM which is no longer connected.
|
|
Radostin Stoyanov |
46abdd7 |
+ * We deal with write()/Send() failures on our own, and prefer not to get killed.
|
|
Radostin Stoyanov |
46abdd7 |
+ * So we ignore SIGPIPEs.
|
|
Radostin Stoyanov |
46abdd7 |
+ *
|
|
Radostin Stoyanov |
46abdd7 |
+ * Pipes are used in various places:
|
|
Radostin Stoyanov |
46abdd7 |
+ * 1) Receiving application page data
|
|
Radostin Stoyanov |
46abdd7 |
+ * 2) Transmitting data to the image streamer
|
|
Radostin Stoyanov |
46abdd7 |
+ * 3) Emitting logs (potentially to a pipe).
|
|
Radostin Stoyanov |
46abdd7 |
+ * Sockets are mainly used in transmitting memory data.
|
|
Radostin Stoyanov |
46abdd7 |
+ */
|
|
Radostin Stoyanov |
46abdd7 |
+ if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
|
|
Radostin Stoyanov |
46abdd7 |
+ pr_perror("Failed to set a SIGPIPE signal ignore.");
|
|
Radostin Stoyanov |
46abdd7 |
+ return 1;
|
|
Radostin Stoyanov |
46abdd7 |
+ }
|
|
Radostin Stoyanov |
46abdd7 |
+
|
|
Radostin Stoyanov |
46abdd7 |
if (optind < argc && !strcmp(argv[optind], "swrk")) {
|
|
Radostin Stoyanov |
46abdd7 |
if (argc != optind + 2) {
|
|
Radostin Stoyanov |
46abdd7 |
fprintf(stderr, "Usage: criu swrk <fd>\n");
|
|
Radostin Stoyanov |
46abdd7 |
@@ -175,21 +193,6 @@ int main(int argc, char *argv[], char *envp[])
|
|
Radostin Stoyanov |
46abdd7 |
}
|
|
Radostin Stoyanov |
46abdd7 |
}
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
- /*
|
|
Radostin Stoyanov |
46abdd7 |
- * The kernel might send us lethal signals when writing to a pipe
|
|
Radostin Stoyanov |
46abdd7 |
- * which reader has disappeared. We deal with write() failures on our
|
|
Radostin Stoyanov |
46abdd7 |
- * own, and prefer not to get killed. So we ignore SIGPIPEs.
|
|
Radostin Stoyanov |
46abdd7 |
- *
|
|
Radostin Stoyanov |
46abdd7 |
- * Pipes are used in various places:
|
|
Radostin Stoyanov |
46abdd7 |
- * 1) Receiving application page data
|
|
Radostin Stoyanov |
46abdd7 |
- * 2) Transmitting data to the image streamer
|
|
Radostin Stoyanov |
46abdd7 |
- * 3) Emitting logs (potentially to a pipe).
|
|
Radostin Stoyanov |
46abdd7 |
- */
|
|
Radostin Stoyanov |
46abdd7 |
- if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
|
|
Radostin Stoyanov |
46abdd7 |
- pr_perror("Failed to set a SIGPIPE signal ignore.");
|
|
Radostin Stoyanov |
46abdd7 |
- return 1;
|
|
Radostin Stoyanov |
46abdd7 |
- }
|
|
Radostin Stoyanov |
46abdd7 |
-
|
|
Radostin Stoyanov |
46abdd7 |
/*
|
|
Radostin Stoyanov |
46abdd7 |
* When a process group becomes an orphan,
|
|
Radostin Stoyanov |
46abdd7 |
* its processes are sent a SIGHUP signal
|
|
Radostin Stoyanov |
46abdd7 |
--
|
|
Radostin Stoyanov |
46abdd7 |
2.34.1
|
|
Radostin Stoyanov |
46abdd7 |
|