break?

Started by newdep, March 01, 2004, 01:11:59 PM

Previous topic - Next topic

newdep

Hello Lutz,



Sorry for all the stormy postings ;-)



How can I break inside the console an event without exiting newlisp?

(ctrl-C drops me out 100%, a signal handler could catch it...)



Norman.
-- (define? (Cornflakes))

Lutz

#1
The Ctrl-C break handler is already in the code (in newlisp.c right at the top before main()) but I have it outcommented because it only works on BSD and MAC OS-X (BSD based.



On Linux and Cygwin it works only the first time and I couldn't figure out why. Probably some stupid oversight in the code or subtle difference in signal handling between Linux and BSD. Incidently I looked up all the signal handling stuff in a LINUX book but it works only on BSD. Perhaps you have some idea?



Would be great to have this for 8.0.





Lutz

newdep

#2
Hello Lutz,



Im not a great C programmer but the following works overhere on Linux,

there must be a return from signal and its in a while loop...



I think you need to have a look at ioctl also, because you use the readline library im not sure if ioctl is needed to control console io that way...But thats not ansi C i guess...



#include <stdio.h>

#include <stdlib.h>

#include <signal.h>



void xsigint()

{

  printf("blablan");

  return;

}



int main()

{

  if (signal(SIGINT, xsigint) == SIG_ERR)

  printf("Error sigint!n");

  while(1);

}
-- (define? (Cornflakes))

newdep

#3
This might clarify your sig_int problem ...



http://www.imaxx.net/~thrytis/glibc/glibc-FAQ.html">http://www.imaxx.net/~thrytis/glibc/glibc-FAQ.html
-- (define? (Cornflakes))

Lutz

#4
thankyou very much for the pointer, this seems to be the point:



>>> http://www.imaxx.net/~thrytis/glibc/glibc-FAQ.html#3.7">http://www.imaxx.net/~thrytis/glibc/glibc-FAQ.html#3.7

BSD signal handlers remain installed once triggered. System V signal handlers work only once, so one must reinstall them each time.

>>>



thanks



Lutz



ps: left you some stuff in http://newlisp.org/download/development/broadcast">http://newlisp.org/download/development/broadcast

newdep

#5
Hello Lutz,



Thanks... I tried it but get a compile error..cant find the bugger though ;-)



gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o pcre.o -g -lm -ldl -lreadline -lncurses -o newlisp

nl-sock.o(.text+0xf63): In function `writeLog':

/newlisp_7504/nl-sock.c:853: undefined reference to `logTraffic'

collect2: ld returned 1 exit status

make[1]: *** [default] Error 1

make[1]: Leaving directory `/newlisp_7504'

make: *** [linux] Error 2





Norman.
-- (define? (Cornflakes))

Lutz

#6
Sorry about this, I did not want to upload an unfinished version. I put newlisp_7505.tgz in the broadcast directory.



Lutz

newdep

#7
Lutz,



I have send you a Private Message on the UDP part from 7505..



Norman.
-- (define? (Cornflakes))

Lutz

#8
thanks



Lutz