diff options
author | sago35 <[email protected]> | 2021-03-05 08:48:25 +0900 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-03-05 11:16:42 +0100 |
commit | 3fdd1a9249ddb8a6b5d85c61892977daf6d02460 (patch) | |
tree | ebe97cafbde37c2b51ce7e26add5faf9224d1bb8 | |
parent | 869baca117224103266ae90608198cce681c2ab3 (diff) | |
download | tinygo-3fdd1a9249ddb8a6b5d85c61892977daf6d02460.tar.gz tinygo-3fdd1a9249ddb8a6b5d85c61892977daf6d02460.zip |
gdb: kill openocd if it does not exit
-rw-r--r-- | main.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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) }() } |