Skip to content

Commit aed37b5

Browse files
committed
WIP: Try a fix for Linux os.Exit stalls.
1 parent 7e7b29d commit aed37b5

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

compiler/natives/src/syscall/syscall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func use(p unsafe.Pointer) {
5050
}
5151

5252
func Exit(code int) {
53-
Syscall(SYS_EXIT, uintptr(code), 0, 0)
53+
Syscall(exitTrap, uintptr(code), 0, 0)
5454
}
5555

5656
// indexByte is copied from bytes package to avoid importing it (since the real syscall package doesn't).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// +build js
2+
3+
package syscall
4+
5+
const exitTrap = SYS_EXIT_GROUP
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// +build js,!linux
2+
3+
package syscall
4+
5+
const exitTrap = SYS_EXIT

compiler/natives/src/syscall/syscall_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
6666
printToConsole(slice)
6767
return uintptr(array.Length()), 0, 0
6868
}
69-
if trap == SYS_EXIT {
69+
if trap == exitTrap {
7070
runtime.Goexit()
7171
}
7272
printWarning()

0 commit comments

Comments
 (0)