Should be pretty easy to have a Go routine blocked in a C call waiting - then 
have the signal handler add an event to a memory queue and wake the C thread. 
Then dispatch to a Go side handler. 

> On Feb 28, 2022, at 1:49 PM, Ian Lance Taylor <i...@golang.org> wrote:
> 
> On Mon, Feb 28, 2022 at 5:08 AM LordRusk <zombiekiller19...@gmail.com> wrote:
>> 
>> It seems this does not work. Any code ran from a C signal handler must be
>> async-signal-safe, no go code is async-signal-safe, so it sigfaults when you
>> try this. https://github.com/golang/go/issues/45499
> 
> 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+unsubscr...@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.
> 
> -- 
> 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/CAOyqgcWEDeVVAmQ2S7NETAddgY3REkX1KJJt5u_OADUKCduTnw%40mail.gmail.com.

-- 
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/6D6E3477-7B06-46D5-AC3D-18BF6641F0EA%40ix.netcom.com.

Reply via email to