Skip to content

Commit d9d178b

Browse files
lmbgopherbot
authored andcommitted
unix: add PthreadSigmask for Linux
Add a syscall wrapper for SYS_RT_SIGPROCMASK and export it as PthreadSigmask. The latter is defined by POSIX and can therefore be implemented by Darwin, etc. later on. Follow the approach used by Signalfd of passing _C__NSIG/8 as sigsetsize. This avoids exporting _C__NSIG and allows the syscall to work with the current definition of Sigset_t, which doesn't match the kernel definition of Sigset_t. Updates golang/go#55349 Change-Id: I49dc93366a7d316d820b0c25ecdef2ebb584634b Reviewed-on: https://go-review.googlesource.com/c/sys/+/435095 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
1 parent 8cfa568 commit d9d178b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

unix/syscall_linux.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,16 @@ func Setitimer(which ItimerWhich, it Itimerval) (Itimerval, error) {
23682368
return prev, nil
23692369
}
23702370

2371+
//sysnb rtSigprocmask(how int, set *Sigset_t, oldset *Sigset_t, sigsetsize uintptr) (err error) = SYS_RT_SIGPROCMASK
2372+
2373+
func PthreadSigmask(how int, set, oldset *Sigset_t) error {
2374+
if oldset != nil {
2375+
// Explicitly clear in case Sigset_t is larger than _C__NSIG.
2376+
*oldset = Sigset_t{}
2377+
}
2378+
return rtSigprocmask(how, set, oldset, _C__NSIG/8)
2379+
}
2380+
23712381
/*
23722382
* Unimplemented
23732383
*/
@@ -2426,7 +2436,6 @@ func Setitimer(which ItimerWhich, it Itimerval) (Itimerval, error) {
24262436
// RestartSyscall
24272437
// RtSigaction
24282438
// RtSigpending
2429-
// RtSigprocmask
24302439
// RtSigqueueinfo
24312440
// RtSigreturn
24322441
// RtSigsuspend

unix/zsyscall_linux.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)