> I don't have Matlab so I can't try anything, but as a general comment I
> would say that if Julia is going to support embedding in the same process
> it has to cooperate with its host on usage of shared resources like
> signals. If Julia is simply initialized, runs some code, shuts down and
> returns then saving the sigactions before jl_init and restoring the
> sigactions after Julia shuts down (and before returning to Matlab), for all
> signals Julia uses, should be sufficient, but initializing and shutting
> down each time is expensive.
>
This is not sufficient, so maybe something else is going wrong, or I'm not
doing it right. It's not that expensive if you're not calling Julia very
often (and not for my purposes).
>
> If Julia is to remain initialized then for signals it probably should add
> its actions as Tim pointed out, keeping the old action and, when a signal
> occurs, do something like:
>
> if in_a_Julia_function then do Julia handler
> else do host action
>
> Of course this doesn't help if Matlab then changes the sigaction again.
> As its not open its not possible to know if this happens.
>
> So in the end it may turn out to be more effective to run Julia in another
> process communicating via shared memory. That would probably (unbenchmarked
> of course :) be better performing than re-initalizing Julia every time a
> piece of Julia code is run.
>
I would agree, but the Julia devs appear to want to make embedding
possible, so that effort may be available. In any case, the overhead of
having to program the communication on both ends is a factor in addition to
performance.