The Python signal handling actually waits until between Python interpretor instructions to dispatch the user python signal handler, it isn't actually running in signal handler context and so the restrictions are no longer relevant. But as it says, that can be an arbitrary delay.
Julia could do something similar with pipes and libuv maybe to allow "normal" code, but again at the cost of arbitrary delay. On Friday, January 15, 2016 at 9:09:58 AM UTC+10, John Travers wrote: > > Well, it works well enough in python as long as all of the restrictions > are adhered to (see https://docs.python.org/2/library/signal.html). > > BTW I opened an issue about this: > https://github.com/JuliaLang/julia/issues/14675 > > On Thursday, January 14, 2016 at 11:27:18 PM UTC+1, [email protected] > wrote: >> >> You are probably going to have to use ccall anyway to do things like save >> state. Only a limited set of system calls are available to signal >> handlers, see http://man7.org/linux/man-pages/man7/signal.7.html, and >> you can't rely on normal Julia IO to only use the allowed ones. Same for >> anything else that uses system calls. >> >> On Thursday, January 14, 2016 at 11:29:26 PM UTC+10, John Travers wrote: >>> >>> I know this, but this can be very important for codes running on >>> simulation servers. Often signals are used to tell a process to save state >>> and shut down as it is going to be moved to another system or the server >>> needs maintenance. I have to handle SIGINT to do exactly this on our >>> simulation systems (currently I run python and C++ codes which can do >>> this). For this reason it would be useful to easily register julia >>> functions as signal handlers so that we can achieve something like this. >>> >>> Of course I could ccall, but I'd rather have an official way to do this. >>> >>> On Thursday, January 14, 2016 at 1:55:04 PM UTC+1, Yichao Yu wrote: >>>> >>>> On Thu, Jan 14, 2016 at 5:37 AM, John Travers <[email protected]> >>>> wrote: >>>> > No, I'm looking for operating system signal handling, like SIGINT >>>> etc. >>>> > Something like the python `signal` module. >>>> >>>> Note that the signal handler is global and julia relies on a number of >>>> them to function correctly. >>>> >>>> > >>>> > >>>> > On Thursday, January 14, 2016 at 11:25:13 AM UTC+1, Eric Forgy wrote: >>>> >> >>>> >> Is this what you are looking for? >>>> >> >>>> >> http://julialang.org/Reactive.jl/ >>>> >> >>>> >> >>>> >> On Thursday, January 14, 2016 at 6:16:20 PM UTC+8, John Travers >>>> wrote: >>>> >>> >>>> >>> Is there a way to handle signals in julia (i.e. to register >>>> handlers >>>> >>> etc.)? >>>> >>> >>>> > >>>> >>>
