CTRL-C in newlisp

Started by newdep, March 05, 2004, 07:27:49 AM

Previous topic - Next topic

newdep

Hello Lutz,



The ctrl-c signaling under console mode is very handy, it realy is.

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



But i just ran into someting funny and that is that its now impossible

to bypass the ctrl-c signal handler. So whenever you now press cltr-c

you will see the (c)ontinue.... message..



Is it possible to bring the ctrl-c signal handel under (error-event)?

That way perhpas people can build there own signal handler for

cltr-c (which could be seens as an error-event?)



Why? well... using 'link.lsp on newlisp programs, user-defined ctrl-c

exists could brighten the exit instead of always having the

(c)ontinue...message and ending up on the console prompt of newlisp..



What do you think of this?



Norman.
-- (define? (Cornflakes))

Lutz

#1
Actually this works already, when after Ctrl-C you respond with (r)eset and hit enter it will go through your error-handler with error# 46= "user-interrupt". Ctr--C is handled like a user invoked error, but on UNIX I have a little menu in front of it. Try this:



(define (myhandler) (println "Error: " (error-text) " occured"))

(error-event 'myhandler)



now hit Ctrl-C and respond with key <R> and <enter> and you will see the userdefined handler in action.



Unfortunately this will not be possible always, if newLISP is stuck in a 'C' function, where it never comes out, only the (c)ontinue and e(x)it functions will work, because I cannot do longjmp() out of the signal handler at all times. There are also other unreliabilities: sometimes the menu doesn't take a response, although this problem almost disapperaed after inserting a fflush(NULL) before the getchar() in the signal handler.



I could suppress the menu completely and let Ctrl-C just fall into the error handler right away, but then you wouldnt be able to interrupt a long 'C' function anymore.



For this reason I have a the (c)ontinue and e(x)it options, which allow you just to continue or exit newLISP completeley. On Win32 it exits automatically or goes through the (r)eset option automatically also reporting in which functions the break happened (similar to error handling).



Also, just finished SIGCHLD handling, so now if the child process finishes the newLISP zombie will be cleaned up automatically. This will be in 7.5.8



Lutz

newdep

#2
Hello Lutz,



I think i have a workaround for the CTRL-C enable/disable choise.



Actualy the (command-line nil) could enable/disable the use of the CTRL-C

sighandler..



If (command-line nil) then sig-handler directly returns back to 'prompt

after pressing cltr-c else enabled and will show the choise selection..



Is that an option perhpas?



Norman.
-- (define? (Cornflakes))

Lutz

#3
sounds like a good idea, look for it in 7.5.8



Lutz