Re: [julia-users] Handling signals/ctrl-c in Julia

2016-06-09 Thread Ulf Worsoe
Hm. That would work. Thank you for that suggestion! On Wednesday, June 8, 2016 at 2:05:26 PM UTC+2, Yichao Yu wrote: > > On Wed, Jun 8, 2016 at 4:39 AM, Ulf Worsoe > wrote: > > In this case the callback function is guaranteed to always be called > from > > the same

Re: [julia-users] Handling signals/ctrl-c in Julia

2016-06-08 Thread Yichao Yu
On Wed, Jun 8, 2016 at 4:39 AM, Ulf Worsoe wrote: > In this case the callback function is guaranteed to always be called from > the same thread that called the original native function (i.e. the Julia > thread). If it is always on the same thread then you can use

Re: [julia-users] Handling signals/ctrl-c in Julia

2016-06-08 Thread Ulf Worsoe
In this case the callback function is guaranteed to always be called from the same thread that called the original native function (i.e. the Julia thread). It also appears to in the current nightly build. On Monday, June 6, 2016 at 1:58:06 PM UTC+2, Yichao Yu wrote: > > On Mon, Jun 6, 2016 at

Re: [julia-users] Handling signals/ctrl-c in Julia

2016-06-06 Thread Yichao Yu
On Mon, Jun 6, 2016 at 6:29 AM, Ulf Worsoe wrote: > The symbol jl_signal_pending is exported, and the following appears to work > (assuming, of course, sig_atomic_t is an int): > > function callback_func() > if unsafe_load(cglobal(:jl_signal_pending, Cint),1) > Cint(0) >

Re: [julia-users] Handling signals/ctrl-c in Julia

2016-06-06 Thread Ulf Worsoe
The symbol jl_signal_pending is exported, and the following appears to work (assuming, of course, sig_atomic_t is an int): function callback_func() if unsafe_load(cglobal(:jl_signal_pending, Cint),1) > Cint(0) return convert(Cint,1) else return convert(Cint,0) end end function

Re: [julia-users] Handling signals/ctrl-c in Julia

2016-06-06 Thread Ulf Worsoe
The symbol jl_signal_pending is exported, and the following appears to work: function callback_func() if unsafe_load(cglobal(:jl_signal_pending, Cint),1) > Cint(0) return convert(Cint,1) else return convert(Cint,0) end end function do_native_call() disable_sigint() do

Re: [julia-users] Handling signals/ctrl-c in Julia

2016-06-06 Thread Ulf Worsoe
I can see that the symbol jl_signal_pending is exported. Can I assume that this is safe to check from the julia thread? So doing something like this should work: function callback_func() if unsafe_load(cglobal(:jl_signal_pending, Cint),1) > Cint(0) end function do_native_call()

Re: [julia-users] Handling signals/ctrl-c in Julia

2016-06-06 Thread Ulf Worsoe
It appears to work in Julia 0.4 - at least I hasn't crashed yet - but I have not really stress tested it. Just disabling SIGINT only gets me half of the way. It will stop the function from crashing, but these calls may run for a long time, and in some cases it may be relevant to manually stop

Re: [julia-users] Handling signals/ctrl-c in Julia

2016-06-03 Thread Yichao Yu
On Fri, Jun 3, 2016 at 4:51 AM, Ulf Worsoe wrote: > I am developing Mosek.jl. > > That library works by creating a task object, adding data to it and calling > a solve function. When a user in interactive mode hits ctrl-c, calls to > native functions are terminated, and that

[julia-users] Handling signals/ctrl-c in Julia

2016-06-03 Thread Ulf Worsoe
I am developing Mosek.jl. That library works by creating a task object, adding data to it and calling a solve function. When a user in interactive mode hits ctrl-c, calls to native functions are terminated, and that leaves the task object in an inconsistent state, meaning that even calling