[gambit-list] Remote REPL

Christian Jaeger christian at pflanze.mine.nu
Wed Dec 5 06:00:30 EST 2007


James Long wrote:
> One last question.  I'd like to get interrupts working, and anything
> ctrl related (like C-d).  I think I can figure out how to implement
> remote interrupts (as long as I can fire off an interrupt in code),
> but I'm not sure how to capture the C-d behavior.  The repl is run in
> a normal OS X terminal.  Any tips?
>   

You can catch Ctl-c (SIGINT interrupts) by setting 
current-user-interrupt-handler, and you can catch other interrupts by 
following the advice in
https://webmail.iro.umontreal.ca/pipermail/gambit-list/2006-January/000529.html
(following that mail, I wrote an "interrupts" chjmodule, ask me for it 
if you're interested).

I'm not sure what to suggest for interrupting the remote side, though; 
if it should be a real signal, you could of course use kill(2), from 
another process on the same machine. If you have multiple scheme threads 
running on the remote node, that's probably not very convenient, though. 
So maybe you could instead run a separate scheme thread on the remote 
side, to which you can send a request to pseudo-interrupt the thread in 
question by throwing an interrupt exception in the context of the latter 
(I haven't done this yet, but you could take a look at how the default 
user-interrupt-handler is written; statprof ("statistical profiler" from 
Guillaume Germain, http://www.iro.umontreal.ca/~germaing/statprof.html) 
might also be instructive as it is getting at the continuation of the 
currently running thread (you want the continuation of a specific thread 
instead, and then I hope that by calling 
##continuation-graft-with-winding you could throw an exception in the 
context of that thread (not sure, though)). I'm sure Marc can give you 
more concrete advice. Note that pure Scheme-level solutions won't 
interrupt C code, for that only a real signal can help, so to make it 
work really well, a two level approach would be useful, first try the 
scheme level, then after a timeout run kill(2). (For kill (and fork 
etc.) my cj-posix scheme module may be helpful (the last version, ask me 
for the current version if you want.)

Christian.




More information about the Gambit-list mailing list