From 6766ace88ac35f217b5e6b6ddab7c30e126a7956 Mon Sep 17 00:00:00 2001 From: liuxu Date: Tue, 26 Nov 2024 15:37:46 +0800 Subject: [PATCH 04/19] bugfix:fix exec --detach for shim v2 Signed-off-by: liuxu --- .../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