diff --git a/main.go b/main.go index bf8a88ad03039eaec0bfe70eb6e6bdc8c06caf50..9dc54b01d80a6b55e0f8074c9f73de7153b6b8c6 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "os" + "runtime" "strconv" "strings" @@ -16,6 +17,11 @@ type term struct { } func main() { + // We must ensure here that we are running on the same thread during + // the execution of dbg. This is due to the fact that ptrace(2) expects + // all commands after PT_ATTACH to come from the same thread. + runtime.LockOSThread() + t := newTerm() if len(os.Args) == 1 {