You can't call Go code directly from the C signal handler, no. But
whatever mechanism you use to make C code aware that a signal occurred
can also be used to make Go code aware that a signal occurred.
> I really wish there was a way to get around this, there is really no go api
> for anything to do with signals beyond what can be implemented cross platform.
>
> for instance, there's been an issue that's almost 8 years old about the siginfo_t
> struct being inaccessible from go.
https://github.com/golang/go/issues/9764
>
> I don't think anything will come of this soon.
Go is an open source project. That issue will be fixed if someone
develops a workable API.
Ian
> On Friday, August 16, 2019 at 9:46:06 PM UTC-7 Ian Lance Taylor wrote:
>>
>> On Tue, Aug 13, 2019 at 1:03 AM hui zhang <
fastf...@gmail.com> wrote:
>> >
>> > in other words
>> > we need a go runtime signal mask .
>> > just google, no such api provided by go yet .
>> > I want know why ?
>> > any workaround?
>>
>> All the details of signal handling in Go can be seen at
>>
https://golang.org/pkg/os/signal.
>>
>> There is no Go API to set the signal mask because the os/signal
>> package is intended to handle that for you.
>>
>> It's hard to combine C and Go code in the same program and have them
>> both do signal handling. If your C program sends itself a signal
>> periodically, then I recommend that you have your C code call
>> sigaction to override the Go signal handler. If the Go code needs to
>> know about the signal, have the C code call a Go function to do so.
>>
>> Ian
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/c81fa217-210e-4d11-a794-722d5cc64b62n%40googlegroups.com.