#include <julia.h>
JULIA_DEFINE_FAST_TLS() // only define this once, in an executable (not in a shared library) if you want fast code.
int main(int argc, char *argv[])
{
jl_init();
JL_TRY {
jl_eval_string("sleep(10)");
}
JL_CATCH {
jl_static_show(JL_STDERR, jl_exception_occurred());
}
jl_atexit_hook(0);
return 0;
}
JULIA_DIR=$(julia -e "print(dirname(Base.Sys.BINDIR))")
gcc -o test -fPIC -I$JULIA_DIR/include/julia -L$JULIA_DIR/lib test.c -ljulia -Wl,-rpath,$JULIA_DIR/lib
I am trying the above c code. When I hit Ctrl+C
(twice), it returns
(randyimac)-jl_eval_string$ ./test
^C^Cfatal: error thrown and no exception handler available.
InterruptException()
jl_mutex_unlock at /Users/julia/buildbot/worker/package_macos64/build/src/./locks.h:143 [inlined]
jl_task_get_next at /Users/julia/buildbot/worker/package_macos64/build/src/partr.c:451
poptaskref at ./task.jl:702
wait at ./task.jl:709 [inlined]
task_done_hook at ./task.jl:444
jl_apply at /Users/julia/buildbot/worker/package_macos64/build/src/./julia.h:1700 [inlined]
jl_finish_task at /Users/julia/buildbot/worker/package_macos64/build/src/task.c:198
start_task at /Users/julia/buildbot/worker/package_macos64/build/src/task.c:697
I wonder what is the correct way to catch this particular error? I read that jl_eval_string
already uses JL_TRY
. Maybe that’s the reason that it is working here.