In single threaded C code, The interrupter loop is guaranteed stop
when crash() is executing,  Now in Go code, however,  the interrupter
loop could still be executing when crash() is running. because there
is no way to interrupt a go routine beside a panic(), but like you
said, i can't induce panic on another go routine, so I can't do what i
want.

Now, I get what you are saying, I need to invest some time on C code's
main loop to make it interruptible by other thread . which maybe what
I need to do.

On Wed, Feb 15, 2017 at 10:56 AM, Ian Lance Taylor <[email protected]> wrote:
> On Wed, Feb 15, 2017 at 10:43 AM, Yucong Sun <[email protected]> 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 executing some "crash()" cleanup function.
>
> Why can't you do exactly that in Go?
>
>
>> Now, I ported the main function to Go, as I demonstrated above, there
>> is no way to "interrupt" C code anymore, so I can't run crash()
>> cleanly as before. This seems to be a limitation of Go, and I couldn't
>> think of any way to work around it.
>
> If you want to implement the precise behavior of a single-threaded C
> program, then you need to write a single-threaded Go program.  But
> that goal is clearly folly.  Don't try to write C code in Go.  When
> you are using Go, write Go code.  That means: arrange your program as
> a Go program.
>
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to