break?

Q&A's, tips, howto's
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

break?

Post by 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.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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("blabla\n");
return;
}

int main()
{
if (signal(SIGINT, xsigint) == SIG_ERR)
printf("Error sigint!\n");
while(1);
}

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

This might clarify your sig_int problem ...

http://www.imaxx.net/~thrytis/glibc/glibc-FAQ.html

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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

Lutz

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Lutz,

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

Norman.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

thanks

Lutz

Locked