interrupt handling

Started by israel, February 20, 2006, 05:44:29 PM

Previous topic - Next topic

israel

I just recently starting using newlisp, and have a problem that I haven't been able to find a solution to.  Newlisp's default for interrupt handling is not what I was expecting for a language that is built for scripting.  If I build a newlisp script for use in a pipeline, e.g.:



cat file | new-lisp-script.lsp | more



then it gets screwy on interrupts.  Specifically, if I ctrl-C or 'q' out of the more (say the input file is a lot bigger than expected), newlisp's interrupt handler goes to the:



    user reset -

    (c)ontinue, (d)ebug, e(x)it, (r)eset:



prompt, but since 'more' has terminated, nothing comes out on the screen, but it's still hanging on user inputer, and more CTRL-C's don't interrupt that.



Now since I know that it's waiting, I can type 'x<Ret>'.  But my point is that I shouldn't need to, and if this script is to be useable by anybody else besides me, then then they likely will not even know that the utitilty is built in newlisp, and that's what the interpreter requires.  So my question is how can I configure the script so that an interrupt immediately exits the entire program?



Secondly, I should be able to ^C out of that prompt also.  So my suggestion for another release is that when it's in the interrupt handler, another CTRL-C should act like an interrupt with no handler.



On the first, I'm even willing to do something like:



(define-interrupt-handler '(lambda () (exit))) if need be, though I think for scripting, either exit-on-interrupt should be the default or it should be an argument such as 'newlisp -Q'.



Bruce

Lutz

#1
you could do this:



(define (CtrlC-handler) (exit))

(signal 2 'CtrlC-handler)


Now the signal 2 (SIGINT when Ctrl-C is pressed) will cause newLISP to exit immediately.



See also: http://newlisp.org/downloads/newlisp_manual.html#signal">http://newlisp.org/downloads/newlisp_manual.html#signal



Lutz

israel

#2
Thanks, that's exactly what I was looking for.



Bruce