[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).
This commit is contained in:
J. Nick Koston
2026-05-07 19:00:23 -05:00
parent 11a8e8866d
commit debf955f8d
+6 -1
View File
@@ -2,12 +2,14 @@
#include "esphome/core/hal.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "core.h"
#include <time.h>
#include <unistd.h>
#include <cerrno>
#include <cstdlib>
#include <cstring>
// 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);