Skip to content

Commit b91438e

Browse files
committed
syscall: fallback to process.exit when available
"go test" currently always fails with "fatal error: all goroutines are asleep - deadlock!". In fact, all programs that use "os.Exit" will fail with this. It turns out that the current "runtime.Goexit" function throws an exception which propagates up which violates the expected behavior of the exit syscall (which should not return). Therefore call "process.exit" when available. Fixes #626
1 parent 4152256 commit b91438e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compiler/natives/src/syscall/syscall_unix.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
6767
return uintptr(array.Length()), 0, 0
6868
}
6969
if trap == SYS_EXIT {
70+
process := js.Global.Get("process")
71+
if process != js.Undefined {
72+
process.Call("exit", a1)
73+
}
7074
runtime.Goexit()
7175
}
7276
printWarning()

0 commit comments

Comments
 (0)