If I observe a directory for changes but send a signal to interrupt the script before any changes happen I got an unhandled error message. This is not the case using the code in the REPL or if there was a change in directory before.
So what I’m doing wrong here? Thx for answers and hints as always.
Here are the code lines (sorry I dont see how to format the code lines nicely):
#handle interruption - not needed in REPL
ccall(:jl_exit_on_sigint, Void, (Cint,), 0)
#directory to observe
dir = “/path_to_dir/”
while true
try w = watch_file(dir,-1)
if w.changed
println("changed")
end
catch x
return error("Recieved interupting signal while watching $dir")
end
end
How I said, if any change happens before the interrupting signal comes all works fine.
Otherwise I got this error:
ERROR (unhandled task failure): InterruptException:
Stacktrace:
[1] process_events at ./libuv.jl:82 [inlined]
[2] wait() at ./event.jl:216
[3] wait(::Condition) at ./event.jl:27
[4] macro expansion at ./distributed/remotecall.jl:230 [inlined]
[5] (::Base.Distributed.##131#132)() at ./event.jl:73
and the script is still running.
Using julia v0.6.2