type Sighandler C.union___sigaction_u
type Sigaction C.struct___sigaction // used in syscalls
-// type Sigaction C.struct_sigaction // used by the C library
+type Usigaction C.struct_sigaction // used by sigaction second argument
type Sigval C.union_sigval
type Siginfo C.siginfo_t
type Timeval C.struct_timeval
func setsig(i int32, fn uintptr, restart bool) {
var sa sigactiont
- memclr(unsafe.Pointer(&sa), unsafe.Sizeof(sa))
sa.sa_flags = _SA_SIGINFO | _SA_ONSTACK
if restart {
sa.sa_flags |= _SA_RESTART
}
func setsigstack(i int32) {
- throw("setsigstack")
+ var osa usigactiont
+ sigaction(uint32(i), nil, &osa)
+ handler := *(*uintptr)(unsafe.Pointer(&osa.__sigaction_u))
+ if handler == 0 || handler == _SIG_DFL || handler == _SIG_IGN || osa.sa_flags&_SA_ONSTACK != 0 {
+ return
+ }
+ var sa sigactiont
+ *(*uintptr)(unsafe.Pointer(&sa.__sigaction_u)) = handler
+ sa.sa_tramp = unsafe.Pointer(funcPC(sigtramp))
+ sa.sa_mask = osa.sa_mask
+ sa.sa_flags = osa.sa_flags | _SA_ONSTACK
+ sigaction(uint32(i), &sa, nil)
}
func getsig(i int32) uintptr {
- var sa sigactiont
- memclr(unsafe.Pointer(&sa), unsafe.Sizeof(sa))
+ var sa usigactiont
sigaction(uint32(i), nil, &sa)
return *(*uintptr)(unsafe.Pointer(&sa.__sigaction_u))
}
func sigprocmask(how uint32, new, old *sigset)
//go:noescape
-func sigaction(mode uint32, new, old *sigactiont)
+func sigaction(mode uint32, new *sigactiont, old *usigactiont)
//go:noescape
func sigaltstack(new, old *stackt)