Skip to content

Commit ea8a04a

Browse files
committed
fallback of os.Exit to runtime.Goexit (fixes gopherjs#371)
1 parent d6f494c commit ea8a04a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

compiler/natives/syscall/syscall_unix.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package syscall
44

55
import (
6+
"runtime"
67
"unsafe"
78

89
"github.com/gopherjs/gopherjs/js"
@@ -65,6 +66,9 @@ func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
6566
printToConsole(slice)
6667
return uintptr(array.Length()), 0, 0
6768
}
69+
if trap == SYS_EXIT {
70+
runtime.Goexit()
71+
}
6872
printWarning()
6973
return uintptr(minusOne), 0, EACCES
7074
}

compiler/natives/syscall/syscall_windows.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
package syscall
44

5+
import "runtime"
6+
57
var minusOne = -1
68

79
func Syscall(trap, nargs, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
@@ -71,6 +73,10 @@ func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped)
7173
return nil
7274
}
7375

76+
func ExitProcess(exitcode uint32) {
77+
runtime.Goexit()
78+
}
79+
7480
func GetCommandLine() (cmd *uint16) {
7581
return
7682
}

0 commit comments

Comments
 (0)