Re: [go-nuts] How to run deferred function in main() on panic() in a goroutine?

2017-02-15 Thread Yucong Sun
15, 2017 at 10:43 AM, Yucong Sun wrote: >> So, to give more background, i am trying to porting a C based >> interpreter to Go. In the single threaded C code, the signal is >> always handled by interrupting whatever code was executing and >> directly exit after executin

Re: [go-nuts] How to run deferred function in main() on panic() in a goroutine?

2017-02-15 Thread Yucong Sun
e cleanup code must run in the same > goroutine/thread, but it seems obscure, that the asynchronous signal > handling *also* needs to run in that thread. > > Anyway. Maybe someone else knows more about all of this than me and can help > you :) > > On Wed, Feb 15, 2017 at 7:26

Re: [go-nuts] How to run deferred function in main() on panic() in a goroutine?

2017-02-15 Thread Yucong Sun
async signals, which I can't do with current tools. On Wed, Feb 15, 2017 at 10:21 AM, Yucong Sun wrote: > https://play.golang.org/p/7Vz0o4ZoQF > > shows that your code doesn't really work. My understanding is once > panic reaches the current goroutine's top of callstack, pr

Re: [go-nuts] How to run deferred function in main() on panic() in a goroutine?

2017-02-15 Thread Yucong Sun
old C code does, which i was porting into go) On Wed, Feb 15, 2017 at 10:14 AM, Yucong Sun wrote: > Thanks axle, but are you sure the code would work? it is essentially > triggering panic on the main go routine while recovering from another > goroutine, isn't that impossible?

Re: [go-nuts] How to run deferred function in main() on panic() in a goroutine?

2017-02-15 Thread Yucong Sun
> } > } > } > > this will get asynchronous signals via os/signal and synchronous signals in > the C-code raising runtime-panics via recover. > > Now, what is *not* possible, is to somehow recover from runtime panics > caused by synchronous signals in *other*

Re: [go-nuts] How to run deferred function in main() on panic() in a goroutine?

2017-02-15 Thread Yucong Sun
hi, Maybe I wasn't clear, I am indeed using os.signal package. But it doesn't do what I want! I want to trigger a panic in main function , seems there is no way to do it by using a signal channel . Thanks -- You received this message because you are subscribed to the Google Groups "golang-n

Re: [go-nuts] cpu profiling in CGO

2017-01-15 Thread Yucong Sun
47 PM Ian Lance Taylor wrote: > On Sun, Jan 15, 2017 at 1:04 AM, Yucong Sun wrote: > > > > Sorry for replying late. > > > > 1: operating system is linux > > 2. golang 1.7 > > 3. I'm statically linking Go with C++ code, so I guess that is > > -bu

Re: [go-nuts] cpu profiling in CGO

2017-01-15 Thread Yucong Sun
Hi Ian, Sorry for replying late. 1: operating system is linux 2. golang 1.7 3. I'm statically linking Go with C++ code, so I guess that is -buildmode=c-archive. Thanks On Tue, Jan 10, 2017 at 1:21 PM Ian Lance Taylor wrote: > On Tue, Jan 10, 2017 at 12:52 PM, Yucong Sun wrote: >

[go-nuts] cpu profiling in CGO

2017-01-10 Thread Yucong Sun
Hi, I've successfully compile and staticlly linked my C++ project and CGO , I was trying to get on demand CPU profling to work, but it keeps generating empty outputs. The CPU profiling page mentioned that if code built in C mode, i need to do something with SIGPROF , but no examples were given