1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-12 08:12:22 +01:00
This commit is contained in:
J. Nick Koston
2025-07-04 10:00:25 -05:00
parent f7ca26eef8
commit 71f78e3a81
4 changed files with 48 additions and 62 deletions

View File

@@ -474,6 +474,14 @@ async def run_binary_and_wait_for_port(
if process.returncode is not None:
error_msg += f"\nProcess exited with code: {process.returncode}"
# Check for common signals
if process.returncode < 0:
sig = -process.returncode
try:
sig_name = signal.Signals(sig).name
error_msg += f" (killed by signal {sig_name})"
except ValueError:
error_msg += f" (killed by signal {sig})"
# Include any output collected so far
if stdout_lines:
@@ -501,6 +509,20 @@ async def run_binary_and_wait_for_port(
if controller_transport is not None:
controller_transport.close()
# Log the exit code if process already exited
if process.returncode is not None:
print(f"\nProcess exited with code: {process.returncode}", file=sys.stderr)
if process.returncode < 0:
sig = -process.returncode
try:
sig_name = signal.Signals(sig).name
print(
f"Process was killed by signal {sig_name} ({sig})",
file=sys.stderr,
)
except ValueError:
print(f"Process was killed by signal {sig}", file=sys.stderr)
# Cleanup: terminate the process gracefully
if process.returncode is None:
# Send SIGINT (Ctrl+C) for graceful shutdown