diff --git a/lib/galaxy/jobs/command_factory.py b/lib/galaxy/jobs/command_factory.py index 896c1caf1617..0e9b2eac6092 100644 --- a/lib/galaxy/jobs/command_factory.py +++ b/lib/galaxy/jobs/command_factory.py @@ -282,7 +282,7 @@ def capture_stdout_stderr(self, stdout_file, stderr_file): if TRAP_KILL_CONTAINER in self.commands: # We need to replace the container kill trap with one that removes the named pipes and kills the container self.commands = self.commands.replace(TRAP_KILL_CONTAINER, "") - trap_command = """trap 'rm "$__out" "$__err"; _on_exit' EXIT""" + trap_command = """trap 'rm "$__out" "$__err" 2> /dev/null || true; _on_exit' EXIT""" self.prepend_command( f"""__out="${{TMPDIR:-.}}/out.$$" __err="${{TMPDIR:-.}}/err.$$" mkfifo "$__out" "$__err" diff --git a/test/unit/app/jobs/test_command_factory.py b/test/unit/app/jobs/test_command_factory.py index 4fa4d45b85f0..7470454a4924 100644 --- a/test/unit/app/jobs/test_command_factory.py +++ b/test/unit/app/jobs/test_command_factory.py @@ -54,7 +54,7 @@ def test_kill_trap_replaced(self): self.job_wrapper.command_line = f"{TRAP_KILL_CONTAINER}{MOCK_COMMAND_LINE}" expected_command_line = self._surround_command(MOCK_COMMAND_LINE).replace( """trap 'rm "$__out" "$__err"' EXIT""", - """trap 'rm "$__out" "$__err"; _on_exit' EXIT""" + """trap 'rm "$__out" "$__err" 2> /dev/null || true; _on_exit' EXIT""" ) self.__assert_command_is(expected_command_line)