Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: access to sigatomic_begin/end in Julia for non-interrupt-safe C calls #2759

Merged
merged 1 commit into from
Apr 5, 2013

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented Apr 4, 2013

See also issue #2622. This adds Julia-callable sigatomic_begin/end functions to temporarily defer SIGINT (ctrl-c) handling, which is essential for long-running C calls that are not interrupt safe. These are wrapped in a higher-level disable_sigint() do ... end construct. Moreover, it also allows one to re-enable SIGINT handling within a disabled region, e.g. for Julia callbacks that can catch the exception.

(This will enable my PyCall module, for example, to defer interrupts during Python calls, which are not interrupt safe. But if the Python has a Julia callback, that Julia callback can still catch InterruptExceptions, convert them to Python KeyboardInterrupt exceptions which are propagated back through Python and returned to the top-level Julia caller, which converts it back to an InterruptException.)

As mentioned in #2622, in the long run we will almost certainly want to make sigatomic the default for all ccall invocations (since C code cannot generally be assumed to be interrupt-safe), and if this is done directly in the LLVM code generation it can be much more efficient than calling disable_sigint from Julia. However, even when that is implemented, we will still want "manual" access to sigatomic_begin/end in Julia in order to re-enable interrupts in callbacks as I mentioned above.

JeffBezanson added a commit that referenced this pull request Apr 5, 2013
RFC: access to sigatomic_begin/end in Julia for non-interrupt-safe C calls
@JeffBezanson JeffBezanson merged commit abda06b into JuliaLang:master Apr 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants