aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorsago35 <[email protected]>2021-03-05 08:48:25 +0900
committerRon Evans <[email protected]>2021-03-05 11:16:42 +0100
commit3fdd1a9249ddb8a6b5d85c61892977daf6d02460 (patch)
treeebe97cafbde37c2b51ce7e26add5faf9224d1bb8
parent869baca117224103266ae90608198cce681c2ab3 (diff)
downloadtinygo-3fdd1a9249ddb8a6b5d85c61892977daf6d02460.tar.gz
tinygo-3fdd1a9249ddb8a6b5d85c61892977daf6d02460.zip
gdb: kill openocd if it does not exit
-rw-r--r--main.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/main.go b/main.go
index 91b9c42af..e5b0c76e2 100644
--- a/main.go
+++ b/main.go
@@ -15,6 +15,7 @@ import (
"path/filepath"
"runtime"
"strings"
+ "sync/atomic"
"syscall"
"time"
@@ -464,8 +465,15 @@ func FlashGDB(pkgName string, ocdOutput bool, options *compileopts.Options) erro
}
defer func() {
daemon.Process.Signal(os.Interrupt)
- // Maybe we should send a .Kill() after x seconds?
+ var stopped uint32
+ go func() {
+ time.Sleep(time.Millisecond * 100)
+ if atomic.LoadUint32(&stopped) == 0 {
+ daemon.Process.Kill()
+ }
+ }()
daemon.Wait()
+ atomic.StoreUint32(&stopped, 1)
}()
}