summaryrefslogtreecommitdiff
path: root/0162-bugfix-fix-exec-detach-for-shim-v2.patch
blob: ef821d9a244743c152f9c2b68ee9f83ff7f0a12d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
From 6766ace88ac35f217b5e6b6ddab7c30e126a7956 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Tue, 26 Nov 2024 15:37:46 +0800
Subject: [PATCH 04/19] bugfix:fix exec --detach for shim v2

Signed-off-by: liuxu <liuxu156@huawei.com>
---
 .../modules/runtime/isula/isula_rt_ops.c      | 11 ++----
 src/daemon/modules/runtime/runtime_common.h   | 35 +++++++++++++++++++
 src/daemon/modules/runtime/shim/shim_rt_ops.c |  4 ++-
 3 files changed, 40 insertions(+), 10 deletions(-)
 create mode 100644 src/daemon/modules/runtime/runtime_common.h

diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index e628c3fe..11288310 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -56,6 +56,7 @@
 #include "utils_file.h"
 #include "console.h"
 #include "shim_constants.h"
+#include "runtime_common.h"
 
 #define SHIM_BINARY "isulad-shim"
 #define RESIZE_FIFO_NAME "resize_fifo"
@@ -1393,14 +1394,6 @@ int rt_isula_rm(const char *id, const char *runtime, const rt_rm_params_t *param
     return 0;
 }
 
-static bool fg_exec(const rt_exec_params_t *params)
-{
-    if (params->console_fifos[0] != NULL || params->console_fifos[1] != NULL || params->console_fifos[2] != NULL) {
-        return true;
-    }
-    return false;
-}
-
 static char *try_generate_random_id()
 {
     char *id = NULL;
@@ -1536,7 +1529,7 @@ int rt_isula_exec(const char *id, const char *runtime, const rt_exec_params_t *p
         }
     }
 
-    args.fg = fg_exec(params);
+    args.fg = rt_fg_exec(params);
     args.id = id;
     args.workdir = workdir;
     args.bundle = bundle;
diff --git a/src/daemon/modules/runtime/runtime_common.h b/src/daemon/modules/runtime/runtime_common.h
new file mode 100644
index 00000000..dde47110
--- /dev/null
+++ b/src/daemon/modules/runtime/runtime_common.h
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
+ * iSulad licensed under the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ *     http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
+ * PURPOSE.
+ * See the Mulan PSL v2 for more details.
+ * Author: liuxu
+ * Create: 2024-11-28
+ * Description: runtime common definition
+ ******************************************************************************/
+
+#ifndef DAEMON_MODULES_RUNTIME_COMMON_H
+#define DAEMON_MODULES_RUNTIME_COMMON_H
+
+#include "runtime_api.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline bool rt_fg_exec(const rt_exec_params_t *params)
+{
+    return params->console_fifos[0] != NULL || params->console_fifos[1] != NULL || params->console_fifos[2] != NULL;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // DAEMON_MODULES_RUNTIME_COMMON_H
diff --git a/src/daemon/modules/runtime/shim/shim_rt_ops.c b/src/daemon/modules/runtime/shim/shim_rt_ops.c
index fc4d8e3a..fce18ade 100644
--- a/src/daemon/modules/runtime/shim/shim_rt_ops.c
+++ b/src/daemon/modules/runtime/shim/shim_rt_ops.c
@@ -36,6 +36,7 @@
 #include "shim_rt_monitor.h"
 #include "supervisor.h"
 #include "isulad_config.h"
+#include "runtime_common.h"
 
 #define EXIT_SIGNAL_OFFSET_X 128
 
@@ -589,7 +590,8 @@ int rt_shim_exec(const char *id, const char *runtime, const rt_exec_params_t *pa
         goto out;
     }
 
-    if (shim_v2_wait(id, params->suffix, exit_code) != 0) {
+    if (rt_fg_exec(params) &&
+        shim_v2_wait(id, params->suffix, exit_code) != 0) {
         ERROR("%s: failed to wait exec process", id);
         ret = -1;
         goto out;
-- 
2.23.0