On Sunday, May 23, 2021 at 12:29:47 AM UTC+2 Ian Lance Taylor wrote: > On Sat, May 22, 2021 at 5:53 AM Manlio Perillo <manlio....@gmail.com> > wrote: > > > > I'm curious to know if sigprocmask is safe/convenient to use in a Go > program. > > It's possible, of course, but it's not particularly convenient. > sigprocmask isn't a good fit for multi-threaded programs, and most Go > programs are multi-threaded. For cases where C programs use > sigprocmask Go programs normally use signal.Notify. signal.Notify > already lets the Go program handle the signal at a convenient time, > which is the main benefit of using sigprocmask in a single-threaded C > program. > > There is a difference, however. With signal.Notify, after receiving the signal you usually exit the program (probably calling atexit functions). However this is not always safe. As an example:
r := acquire(...) atexit(r.release) In a Go program it may be possible that the atexit function is not called before exit is called by Notify. Thanks -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/1c086d0e-86b7-4365-85d9-4b1ca30434een%40googlegroups.com.