From be7a7edc2606b00efeb6609a3a20d2a2486b03d9 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Tue, 10 Dec 2024 13:20:00 +0100 Subject: [PATCH] bug when copying the shell files for missions 29 and 30 when no compiler is found, the shell file were copied with a shebang of "#!/usr/bin/env bash", so that their names wasn't used by ps. (Instead, the processes appeared with a name of "bash") --- missions/processes/00_shared/init.sh | 2 +- missions/processes/01_ps_kill/init.sh | 8 ++++++-- missions/processes/02_ps_kill_signal/init.sh | 11 +++++++---- missions/processes/03_pstree_kill/init.sh | 9 ++++----- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/missions/processes/00_shared/init.sh b/missions/processes/00_shared/init.sh index e40e1f87..3d0aade6 100644 --- a/missions/processes/00_shared/init.sh +++ b/missions/processes/00_shared/init.sh @@ -18,7 +18,7 @@ _mission_init() ( "$GSH_TMP/test-proc-name" & PID=$! name=$(my_ps $PID | grep $PID | grep -v sh | grep "test-proc-name") - # kill -9 $PID + kill -9 $PID if [ -z "$name" ] then echo "$(eval_gettext "Process names should be equal to the corresponding filename for mission \$MISSION_NAME.")" >&2 diff --git a/missions/processes/01_ps_kill/init.sh b/missions/processes/01_ps_kill/init.sh index f92c82b4..50143132 100644 --- a/missions/processes/01_ps_kill/init.sh +++ b/missions/processes/01_ps_kill/init.sh @@ -46,8 +46,12 @@ _install_script() ( fi mission_source "$MISSION_DIR/deps.sh" || return 1 - cp "$MISSION_DIR/spell.sh" "$GSH_TMP/$(gettext "spell")" - chmod 755 "$GSH_TMP/$(gettext "spell")" + # make sure the shebang for the spell.sh script is a real path to sh + # otherwise, ps will not use the filename as the process name... + sh=$(command -v sh) + echo "#! $sh" > "$GSH_TMP/$(gettext "spell")" + cat "$MISSION_DIR/spell.sh" >> "$GSH_TMP/$(gettext "spell")" + chmod +x "$GSH_TMP/$(gettext "spell")" ) if _compile || _install_script diff --git a/missions/processes/02_ps_kill_signal/init.sh b/missions/processes/02_ps_kill_signal/init.sh index 3af7450d..bf89d59e 100644 --- a/missions/processes/02_ps_kill_signal/init.sh +++ b/missions/processes/02_ps_kill_signal/init.sh @@ -1,7 +1,6 @@ #!/usr/bin/env sh _compile() ( - if command -v gcc >/dev/null then CC=gcc @@ -59,9 +58,13 @@ _install_script() ( return 1 fi mission_source "$MISSION_DIR/deps.sh" || return 1 - cp "$MISSION_DIR/spell.sh" "$GSH_TMP/$(gettext "spell")" - chmod 755 "$GSH_TMP/$(gettext "spell")" - + # + # make sure the shebang for the spell.sh script is a real path to sh + # otherwise, ps will not use the filename as the process name... + sh=$(command -v sh) + echo "#! $sh" > "$GSH_TMP/$(gettext "spell")" + cat "$MISSION_DIR/spell.sh" >> "$GSH_TMP/$(gettext "spell")" + chmod +x "$GSH_TMP/$(gettext "spell")" ) if _compile || _install_script diff --git a/missions/processes/03_pstree_kill/init.sh b/missions/processes/03_pstree_kill/init.sh index bcbbb13a..d360e456 100644 --- a/missions/processes/03_pstree_kill/init.sh +++ b/missions/processes/03_pstree_kill/init.sh @@ -1,7 +1,6 @@ #!/usr/bin/env sh _compile() ( - if ! command -v pstree >/dev/null then echo "$(eval_gettext "The command 'pstree' is required for mission \$MISSION_NAME. @@ -81,21 +80,21 @@ _install_script() ( echo "#! $sh" > "$GSH_TMP/$(gettext "nice_fairy")" cat "$MISSION_DIR/nice_fairy.sh" >> "$GSH_TMP/$(gettext "nice_fairy")" - chmod 755 "$GSH_TMP/$(gettext "nice_fairy")" + chmod +x "$GSH_TMP/$(gettext "nice_fairy")" mkdir -p "$GSH_TMP/fairy/" echo "#! $sh" > "$GSH_TMP/fairy/$(gettext "spell")" cat "$MISSION_DIR/fairy/spell.sh" >> "$GSH_TMP/fairy/$(gettext "spell")" - chmod 755 "$GSH_TMP/fairy/$(gettext "spell")" + chmod +x "$GSH_TMP/fairy/$(gettext "spell")" echo "#! $sh" > "$GSH_TMP/$(gettext "mischievous_imp")" cat "$MISSION_DIR/mischievous_imp.sh" >> "$GSH_TMP/$(gettext "mischievous_imp")" - chmod 755 "$GSH_TMP/$(gettext "mischievous_imp")" + chmod +x "$GSH_TMP/$(gettext "mischievous_imp")" mkdir -p "$GSH_TMP/imp/" echo "#! $sh" > "$GSH_TMP/imp/$(gettext "spell")" cat "$MISSION_DIR/imp/spell.sh" >> "$GSH_TMP/imp/$(gettext "spell")" - chmod 755 "$GSH_TMP/imp/$(gettext "spell")" + chmod +x "$GSH_TMP/imp/$(gettext "spell")" )