Re: [go-nuts] how cgo handle user define signal ? need go pass the signal handle to c

2022-02-28 Thread Robert Engels
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 wrote: > > On Mon, Feb 28, 2022 at 5:08 AM LordRusk

Re: [go-nuts] how cgo handle user define signal ? need go pass the signal handle to c

2022-02-28 Thread Ian Lance Taylor
On Mon, Feb 28, 2022 at 5:08 AM LordRusk 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

Re: [go-nuts] how cgo handle user define signal ? need go pass the signal handle to c

2022-02-28 Thread LordRusk
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 I really wish there was a way to get around this, there is really no go api for anything to

Re: [go-nuts] how cgo handle user define signal ? need go pass the signal handle to c

2019-08-16 Thread Ian Lance Taylor
On Tue, Aug 13, 2019 at 1:03 AM hui zhang 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

Re: [go-nuts] how cgo handle user define signal ? need go pass the signal handle to c

2019-08-13 Thread hui zhang
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? -- 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

Re: [go-nuts] how cgo handle user define signal ? need go pass the signal handle to c

2019-08-13 Thread hui zhang
I found the case is like this c code IgnoreSignal(42); while(1) { GoSleep(10);//simulate some call in go runtime , the runtime call stack is in last mail int signo = sigwaitinfo(_set, _info); //will use this signo to do something // usleep(1000*1000); printf("sleep 10s \n"); // raise(42); }

[go-nuts] how cgo handle user define signal ? need go pass the signal handle to c

2019-08-12 Thread hui zhang
I am trying to extend a old c program with go.Add websocket ability to this c program. first build go as a .so dynamic lib then link the so lib in c program I run the cgo ok in an example program. But when integrate with old c program, c program will send a signal 42 to itself periodly.