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 runTest(portOverride string, baudOverride int, args []string) error {
if err != nil {
return fmt.Errorf("open %s: %w", port, err)
}
registerShutdown(func() { _ = sp.Close() })
enableShutdownOnInterrupt()
defer sp.Close()
if !*verbose {