Re: [julia-users] Re: signals handling

2014-06-17 Thread Stephen Chisholm
That's a good point regarding code gen and garbage collection, etc.. I should be able to work with this for now but definitely look forward to a safer first-class mechanism. Is there an issue opened for this on github? On Tuesday, 17 June 2014 12:36:02 UTC-3, Stefan Karpinski wrote: > > There's

Re: [julia-users] Re: signals handling

2014-06-17 Thread Stefan Karpinski
There's very few things you can safely do in a signal handler. Calling a julia function can potentially lead to code generation, GC, etc., all of which is bad news in a signal handler. That's why we need a first-class mechanism for this: install a Julia function as a handler and the system arranges

Re: [julia-users] Re: signals handling

2014-06-17 Thread Stephen Chisholm
I like the idea of an interrupt handling mechanism. What do you see that would make the signal/libc approach unreliable? On Tuesday, 17 June 2014 12:18:11 UTC-3, Stefan Karpinski wrote: > > That is very unlikely to be reliable, but it's cool that it works. I think > that we probably should chan

Re: [julia-users] Re: signals handling

2014-06-17 Thread Stefan Karpinski
That is very unlikely to be reliable, but it's cool that it works. I think that we probably should change SIGINT from raising a normal error to triggering some kind of interrupt handling mechanism (which can in turn raise an error by default). On Tue, Jun 17, 2014 at 10:41 AM, Stephen Chisholm w

[julia-users] Re: signals handling

2014-06-17 Thread Stephen Chisholm
I'm able to register a callback function using signal in libc, see the code below. SIGINT=2 function catch_function(x) println("caught signal $x") exit(0)::Nothing end catch_function_c = cfunction(catch_function, None, (Int64,)) ccall((:signal, "libc"), Void, (Int64, Ptr{Void}), SIGINT,

[julia-users] Re: signals handling

2014-06-17 Thread Stephen Chisholm
I'm able to catch the InterruptException with the code below when running in the REPL, but it doesn't seem to get thrown when running the code in a script. while true try sleep(1) println("running...") catch err println("error: $err") end end On Monday, 16 June 20