newLISP Fan Club

Forum => newLISP in the real world => Topic started by: newdep on March 01, 2004, 01:11:59 PM

Title: break?
Post by: newdep on March 01, 2004, 01:11:59 PM
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.
Title:
Post by: Lutz on March 01, 2004, 01:33:53 PM
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
Title:
Post by: newdep on March 01, 2004, 01:48:40 PM
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);

}
Title:
Post by: newdep on March 01, 2004, 02:53:07 PM
This might clarify your sig_int problem ...



http://www.imaxx.net/~thrytis/glibc/glibc-FAQ.html
Title:
Post by: Lutz on March 01, 2004, 04:13:26 PM
thankyou very much for the pointer, this seems to be the point:



>>> 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
Title:
Post by: newdep on March 01, 2004, 05:18:36 PM
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.
Title:
Post by: Lutz on March 02, 2004, 04:27:05 AM
Sorry about this, I did not want to upload an unfinished version. I put newlisp_7505.tgz in the broadcast directory.



Lutz
Title:
Post by: newdep on March 02, 2004, 06:40:21 AM
Lutz,



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



Norman.
Title:
Post by: Lutz on March 02, 2004, 08:31:47 AM
thanks



Lutz