System V curses nodelay() broke on SunOS 4.0.0??

Edward T Spire ets at wrkgrp.COM
Wed Apr 24 03:46:09 AEST 1991


Perhaps I'm doing something wrong and one of you folks can see it...

I'm writing a keyboard test utility, and I'm at the spot where I'm trying
to see exactly what character(s) are coming from a particular key.

So I set nodelay() and go into a loop, sleeping a second and seeing
if getch() has any input for me.  If not, I keep looping.  If so,
I take all that getch() has buffered up as what the key sent.

Well, this works fine on all kinds of platforms, but not on my old
Sun-3 running SunOS 4.0.0.  There, once you fall on any key, getch()
just starts returning 0, and never stops.

Here's a test program that shows the problem.  Run it without touching
the keyboard and it shows 20 getch() return codes of -1.  On most
platforms, if you type keys, getch() hands them to the program, and
the program echos them back to the screen, and then getch()
goes back to handing it -1's while the buffer is empty.  On the
Sun-3 SunOS 4.0.0 once you fall on any key, all getch() ever returns
from that point on is 0.

#include <ctype.h>
#include <stdio.h>
#define NLS 1
#include <curses.h>
WINDOW *win;
main(argc, argv)
int argc;
char *argv[];
{
  int i, j;
  win =  initscr();
  keypad(stdscr, TRUE);
  raw();
  noecho();
  nonl();
  notimeout(stdscr,TRUE);
  clear();
  nodelay(stdscr,TRUE);
  for (i=0;i<20;i++)
  {
    sleep(1);
    j = getch();
    move(i,0);
    printw("%i",j);
    refresh();
  }
  endwin();
  exit(0);
}

And another minor point, refresh() doesn't seem to do any output if
there's data in the input buffer!  That doesn't seem right to me, and
makes me even more suspicious that I'm just plain doing something
wrong here...

Anybody got any ideas?

========================================================================

Ed Spire                           email: ets at wrkgrp.com      (on uunet)
The Workstation Group              voice: 800-228-0255
6300 River Road, Suite 700            or  708-696-4800
Rosemont, Illinois  60018            fax: 708-696-2277



More information about the Comp.unix.programmer mailing list