From 35f2e6d9aa158ef7a0d8e0b8dfe8d88b84640caf Mon Sep 17 00:00:00 2001 From: Miki Date: Thu, 27 Apr 2023 23:54:46 -0700 Subject: [PATCH] Use `exec` in the CLI shell scripts to prevent new process creation Signed-off-by: Miki --- CHANGELOG.md | 1 + scripts/use_node | 4 ++-- src/dev/build/tasks/bin/scripts/opensearch-dashboards | 2 +- src/dev/build/tasks/bin/scripts/opensearch-dashboards-plugin | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38161efa4829..c621e5ceea2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -193,6 +193,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bump `styled-components` from 5.3.5 to 5.3.9 ([#3678](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3678)) - Bump `js-yaml` from 3.14.0 to 4.1.0 ([#3770](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3770)) - Bump `oui` from `1.0.0` to `1.1.1` ([#3884](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3884)) +- Use `exec` in the CLI shell scripts to prevent new process creation ([#3955](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3955)) - Adding @ZilongX and @Flyingliuhub as maintainers. ([#4137](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4137)) ### 🪛 Refactoring diff --git a/scripts/use_node b/scripts/use_node index f39a39434db1..f32ecbcb833a 100755 --- a/scripts/use_node +++ b/scripts/use_node @@ -91,7 +91,7 @@ fi # If a file path was provided for execution, prefix with OSD_HOME; use relative paths to avoid the need for this. if [ ! -z "$OSD_USE_NODE_JS_FILE_PATH" ]; then - NODE_OPTIONS="$OSD_NODE_OPTS_PREFIX $OSD_NODE_OPTS $NODE_OPTIONS" "${NODE}" "${OSD_HOME}${OSD_USE_NODE_JS_FILE_PATH}" "${@}" + NODE_OPTIONS="$OSD_NODE_OPTS_PREFIX $OSD_NODE_OPTS $NODE_OPTIONS" exec "${NODE}" "${OSD_HOME}${OSD_USE_NODE_JS_FILE_PATH}" "${@}" elif [ $# -ne 0 ]; then - NODE_OPTIONS="$OSD_NODE_OPTS_PREFIX $OSD_NODE_OPTS $NODE_OPTIONS" "${NODE}" "${@}" + NODE_OPTIONS="$OSD_NODE_OPTS_PREFIX $OSD_NODE_OPTS $NODE_OPTIONS" exec "${NODE}" "${@}" fi diff --git a/src/dev/build/tasks/bin/scripts/opensearch-dashboards b/src/dev/build/tasks/bin/scripts/opensearch-dashboards index 49c41011da7d..c7eae94b4996 100755 --- a/src/dev/build/tasks/bin/scripts/opensearch-dashboards +++ b/src/dev/build/tasks/bin/scripts/opensearch-dashboards @@ -28,4 +28,4 @@ done # Get an absolute path for OSD_HOME OSD_HOME="$(cd "$(dirname "${SCRIPT}")/.."; pwd)" -OSD_NODE_OPTS_PREFIX="--no-warnings --max-http-header-size=65536" OSD_USE_NODE_JS_FILE_PATH=/src/cli/dist NODE_ENV=production ${OSD_HOME}/bin/use_node "${@}" +OSD_NODE_OPTS_PREFIX="--no-warnings --max-http-header-size=65536" OSD_USE_NODE_JS_FILE_PATH=/src/cli/dist NODE_ENV=production exec ${OSD_HOME}/bin/use_node "${@}" diff --git a/src/dev/build/tasks/bin/scripts/opensearch-dashboards-plugin b/src/dev/build/tasks/bin/scripts/opensearch-dashboards-plugin index 6af40438d13b..a8d9829cc3c1 100755 --- a/src/dev/build/tasks/bin/scripts/opensearch-dashboards-plugin +++ b/src/dev/build/tasks/bin/scripts/opensearch-dashboards-plugin @@ -28,4 +28,4 @@ done # Get an absolute path for OSD_HOME OSD_HOME="$(cd "$(dirname "${SCRIPT}")/.."; pwd)" -OSD_NODE_OPTS_PREFIX="--no-warnings" OSD_USE_NODE_JS_FILE_PATH=/src/cli_plugin/dist NODE_ENV=production ${OSD_HOME}/bin/use_node "${@}" +OSD_NODE_OPTS_PREFIX="--no-warnings" OSD_USE_NODE_JS_FILE_PATH=/src/cli_plugin/dist NODE_ENV=production exec ${OSD_HOME}/bin/use_node "${@}"