From 795f9f56bd33ed382ae1e68300247ef651d77864 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Sun, 16 Apr 2023 19:57:48 +1400
Subject: [PATCH 43/46] isulad-shim: fix log loss bug

Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
 src/cmd/isulad-shim/process.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/cmd/isulad-shim/process.c b/src/cmd/isulad-shim/process.c
index 02609911..a676e7ce 100644
--- a/src/cmd/isulad-shim/process.c
+++ b/src/cmd/isulad-shim/process.c
@@ -1348,6 +1348,12 @@ int process_signal_handle_routine(process_t *p, const pthread_t tid_accept, cons
         destroy_io_thread(p, i);
     }
 
+    if (!p->state->exec) {
+        // if log did not contain "/n", print remaind container log when exit isulad-shim
+        shim_write_container_log_file(p->terminal, STDID_OUT, NULL, 0);
+        shim_write_container_log_file(p->terminal, STDID_ERR, NULL, 0);
+    }
+
     if (ret == SHIM_ERR_TIMEOUT) {
         write_message(g_log_fd, INFO_MSG, "Wait %d timeout", p->ctr_pid);
         exit(SHIM_EXIT_TIMEOUT);
-- 
2.25.1

