Skip to content

Commit

Permalink
!2538 bugfix:fix exec --detach for shim v2
Browse files Browse the repository at this point in the history
From: @liuxu180400617 
Reviewed-by: @xuxuepeng, @taotao-sauce 
Signed-off-by: @taotao-sauce
  • Loading branch information
openeuler-ci-bot authored and gitee-org committed Nov 29, 2024
2 parents 67cd3a1 + 6766ace commit 889a43f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
11 changes: 2 additions & 9 deletions src/daemon/modules/runtime/isula/isula_rt_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
35 changes: 35 additions & 0 deletions src/daemon/modules/runtime/runtime_common.h
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion src/daemon/modules/runtime/shim/shim_rt_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 889a43f

Please sign in to comment.