From debf955f8d50257beeae5f0aba171d5a691b2910 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 7 May 2026 19:00:23 -0500 Subject: [PATCH] [host][ota] Log execv() failure on OTA re-exec execv only returns on failure. Surface the errno so a missing or non-executable staged binary is diagnosable instead of silently falling back to exit(0). --- esphome/components/host/hal.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/esphome/components/host/hal.cpp b/esphome/components/host/hal.cpp index 4f4ca839d1..9108c1ea9d 100644 --- a/esphome/components/host/hal.cpp +++ b/esphome/components/host/hal.cpp @@ -2,12 +2,14 @@ #include "esphome/core/hal.h" #include "esphome/core/helpers.h" +#include "esphome/core/log.h" #include "core.h" #include #include #include #include +#include // Empty host namespace block to satisfy ci-custom's lint_namespace check. // HAL functions live in namespace esphome (root) — they are not part of the @@ -57,7 +59,10 @@ void arch_restart() { if (const char *target = host::get_reexec_path()) { char **argv = host::get_argv(); if (argv != nullptr) { - execv(target, argv); // only returns on failure + execv(target, argv); + // execv only returns on failure. + ESP_LOGE("host", "execv('%s') failed: %s", target, std::strerror(errno)); + exit(1); } } exit(0);