From 53d5c0d5b616f7515e514524882fcfee0cecf2cd Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sat, 3 Aug 2024 11:52:43 +1000 Subject: [PATCH] AP_HAL_SITL: work around bug in dash --- libraries/AP_HAL_SITL/system.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_SITL/system.cpp b/libraries/AP_HAL_SITL/system.cpp index 81c5b4941b0c07..358aa0765b4d78 100644 --- a/libraries/AP_HAL_SITL/system.cpp +++ b/libraries/AP_HAL_SITL/system.cpp @@ -96,6 +96,13 @@ static void run_command_on_ownpid(const char *commandname) p = progname; } + // work around a bug in dash; its manpage says it searches $PATH + // but it does't. https://github.com/ArduPilot/ardupilot/issues/24245 + const char *cmd_fmt = "sh %s %d >%s 2>&1"; + if (getenv("AP_DASH_HACKERY")) { + cmd_fmt = "sh -c \"%s %d\" >%s 2>&1"; + } + char output_filepath[80]; snprintf(output_filepath, ARRAY_SIZE(output_filepath), @@ -106,7 +113,7 @@ static void run_command_on_ownpid(const char *commandname) char cmd[200]; snprintf(cmd, sizeof(cmd), - "sh %s %d >%s 2>&1", + cmd_fmt, command_filepath, (int)getpid(), output_filepath);