Handle a signal: Difference between revisions
Content added Content deleted
m (added missing </lang>) |
|||
Line 817:
<lang Julia>
ccall(:jl_exit_on_sigint,
function timeit()
ticks = 0
try
end
catch
end
end
println()▼
@time timeit()
▲println("Done.")
</lang>
The tricky bit for this task is the <code>ccall</code>, which tells the <code>main()</code> running Julia to pass SIGINT on to Julia as an error. This call is not needed when running this code in Julia's REPL, which has the desired behavior by default.
{{out}}
<pre>
Line 843 ⟶ 846:
8
9
10
11
6.020844 seconds (32.06 k allocations: 1.658 MiB)
Done.
</pre>
|