On Wed, Feb 15, 2017 at 10:26 AM, Yucong Sun <sunyuc...@gmail.com> wrote:
> Also, my cleanup function must be tied directly with C loop, because
> they are sharing the same underlaying memory/state  . If I directly
> run cleanup() while C loop was running, there could be race.
>
> So that leaves me with no choice, i must be able to panic on the C
> loop's go-routine on async signals, which I can't do with current
> tools.

I sort of feel like you've set yourself an impossible task by saying
"I must induce a panic on the main goroutine."  You can't do that,
except by having the main goroutine sit around waiting on a channel
telling it when to panic.

But that is not your real problem.  I think you should step back and
figure out what your real problem is.  If your real problem is "I want
to do something when the program exits," then that is easy enough to
do by putting that thing into function F, and having a separate
goroutine that listens on an os/signal channel and invokes F and then
os.Exit when a signal arrives.

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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to