Close UART gracefully on SIGINT/SIGTERM in goTool.

Go exits on Ctrl+C without running defers, leaving the serial port locked; register shutdown hooks for serve and CLI commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-31 16:40:22 +02:00
co-authored by Cursor
parent 0eea27a876
commit e4ce18edd8
4 changed files with 102 additions and 5 deletions
+2
View File
@@ -62,6 +62,8 @@ func main() {
if err != nil {
log.Fatalf("open serial: %v", err)
}
registerShutdown(func() { _ = sp.Close() })
enableShutdownOnInterrupt()
defer sp.Close()
switch cmd {
case "version":