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(&signal_set, &signal_info); //will use this signo
to do something ....
// usleep(1000*1000);
printf("sleep 10s \n");
// raise(42);
}

go code
//export IgnoreSignal
func IgnoreSignal(sig int) {
    signal.Ignore(syscall.Signal(sig))
}

//export GoSleep
func GoSleep(x int) {
    time.Sleep(time.Duration(x) * time.Second)
}

go build an  so lib ,  c link this so
run app
send signal like below
sigqueue(pid, 42, val);

go will catch that signal ,  and  but ignore it and delete it
what I expect  is passing the signal to  *sigwaitinfo*

hui zhang <fastfad...@gmail.com> 于2019年8月13日周二 上午9:58写道:

> 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.
> this cause so lib terminate
>
> rogram received signal SIG42, Real-time event 42.
> [Switching to Thread 0xa53c6b70 (LWP 14957)]
> runtime.futex () at /usr/local/go/src/runtime/sys_linux_386.s:444
> 444 /usr/local/go/src/runtime/sys_linux_386.s: No such file or directory.
> in /usr/local/go/src/runtime/sys_linux_386.s
> Missing separate debuginfos, use: debuginfo-install WBXcms-3.7.0-494.i686
> (gdb) bt
> #0 runtime.futex () at /usr/local/go/src/runtime/sys_linux_386.s:444
> #1 0xb7b04c2a in runtime.futexsleep (addr=0xb7fa47ac, val=0, ns=-1) at
> /usr/local/go/src/runtime/os_linux.go:46
> #2 0xb7ae5437 in runtime.notesleep (n=0xb7fa47ac) at
> /usr/local/go/src/runtime/lock_futex.go:151
> #3 0xb7b0c8f4 in runtime.stopm () at /usr/local/go/src/runtime/proc.go:1936
> #4 0xb7b0d848 in runtime.findrunnable (gp=@0x74421300, inheritTime=@0x0)
> at /usr/local/go/src/runtime/proc.go:2399
> #5 0xb7b0e507 in runtime.schedule () at
> /usr/local/go/src/runtime/proc.go:2525
> #6 0xb7b0edac in runtime.goexit0 (gp=0x744000e0) at
> /usr/local/go/src/runtime/proc.go:2722
> #7 0xb7b2f868 in runtime.mcall () at
> /usr/local/go/src/runtime/asm_386.s:345
> #8 0xb7b2f7c0 in runtime.rt0_go () at
> /usr/local/go/src/runtime/asm_386.s:241
> #9 0xb7b2f7c7 in runtime.rt0_go () at
> /usr/local/go/src/runtime/asm_386.s:246
> #10 0x00
>
> My question is
> *how go so lib ignore this signal 42,  and pass the signal handle to old c
> program.*
>
> Thanks
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/1YvP-5V6xSI/unsubscribe.
> To unsubscribe from this group and all its topics, 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/22745e49-1d43-4e3a-9d78-20ff6bb20d4e%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/22745e49-1d43-4e3a-9d78-20ff6bb20d4e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAF7uC_vecUj34DuYteEARMxanWNvGxMT_pWj%3DLjCz7OigFPtvw%40mail.gmail.com.

Reply via email to