I cannot seem to be able to use atexit properly, in the context of catching Ctrl-C when running a script in Julia 1.7.2:
function main()
atexit(() -> println("caught"))
println("started program")
sleep(5)
println("done")
end
if abspath(PROGRAM_FILE) == @__FILE__
main()
end
Under Windows Terminal the output is
C:\Users\michele.zaffalon> julia script.jl
started program
# Ctrl-C pressed
C:\Users\michele.zaffalon>
and under git bash
$ julia script.jl
started program
# Ctrl-C pressed
Segmentation fault