Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!brahms.udel.edu!weave From: weave@brahms.udel.edu (Ken Weaverling) Newsgroups: comp.unix.sysv386 Subject: Curses bug in halfdelay() ? Keywords: curses halfdelay bug sysv Message-ID: <17068@brahms.udel.edu> Date: 24 Dec 90 00:21:06 GMT Distribution: na Organization: University of Delaware Lines: 61 I am trying to get the halfdelay() routine in curses to implement a timeout on a getch() call. It simply blocks and doesn't return. This same test program I set up (included below) works fine on a Sun 4 using /usr/5bin/cc to compile. I have tried cc and gcc on my box, but none work. Machine and OS specifics: Prime EXL 325, 386 Multibus II box AT&T Unix Sys V 3.1 version 2 What I have tried to resolve problem: Compiled on a Sun 4 with /usr/5bin/cc. Works as advertised Tried sending an alarm (signal 14) to the process to see if some code in curses set an alarm() and signal trap. No go, the program aborted with an Alarm Call Read the manual over and over to see if I was missing something. Since this works on a Sun, I doubt that the problem is with my code. So I'd like to determine if the problem is limited to my machine, or is a bug that appears in other 386 UNIX implementations. Another question: If this is a bug and I have to give up hope on this, I was planning on just using an alarm() for one second just before the call to getch(). Is there any problems that can crop up with this approach? I don't want to use nodelay() to stop blocking since I don't want to run some tight CPU intensive loop looking for something to do. Thanks and Happy Whatever! (sample code next) #include main() { char linebuf[80]; int keypress = 0; initscr(); noecho(); /* I have also tried leaving this out and putting in cbreak() */ halfdelay(20); addstr("Ready to do keyboard timeout test. Press q when done."); while (keypress != 'q') { addstr("\nEnter a key: "); keypress = getch(); if (keypress == ERR) { addstr("\nYou did not respond in time!"); refresh(); sleep(1); } else { sprintf(linebuf, "\nYou pressed the %c key", keypress); addstr(linebuf); refresh(); sleep(1); } } endwin(); } -- >>>---> Ken Weaverling >>>----> weave@brahms.udel.edu