From: glenn@fs.com.au (Glenn Huxtable)
Subject: Odd curses bug - redirected stdout.
Date: Thu, 26 Jan 1995 11:02:56 GMT [thread overview]
Message-ID: <1995Jan26.110256.21416@fs.com.au> (raw)
Can anyone explain this wierd behaviour of OSF1 curses?
Curses fails to honour 'nonl', 'noecho' and 'cbreak' (at least) if
stdout has been redirected?
Before you say that I'm silly to expect curses to work if stdout is redirected,
let me say "it fails even if stdout is redirected to stdout!"
Try the following trivial test program. I call it 'ctest'. It shoud set
nonl, noecho and cbreak, then read characters. For each character read, it
should:
1) NOT echo the character (noecho)
2) immediately (nonl + cbreak) print a '.' on the screen.
------------------------------------------------------------------------
#include <curses.h>
main(argc, argv)
int argc; char **argv;
{
int c;
initscr();
cbreak();
noecho();
nonl();
while (c=getch() ) {
if (c=='q') {
endwin();
exit(0);
}
addch('.');
refresh();
}
}
------------------------------------------------------------------------
If you run 'ctest' you should see how it is *expected* to work.
Now, try either of the following, to see it fail:
ctest > /dev/tty
ctest > `tty`
In both cases, it echo's the characters typed, and line buffers them (doesn't
read and print the dots until <return> is pressed).
I might add, this fails under the default curses (SYSV-ish), but appears to
work under the BSD curses (compile with -D_BSD=1).
This test also succeeds under Solaris, HPUX, Ultrix and BSDI curses.
For the life of me, I can't see how curses can tell the difference between
stdout pointing to /dev/ttyp0 (for example), stoud redirected to /dev/ttyp0,
or stdout pointing to /dev/tty (which returns a handle to /dev/ttyp0).
It just occured to me that it could be something environmental that the shell
was doing in redirecting stdout (fiddling processgroups etc), but no - it
fails under /bin/sh, /bin/ksh and /bin/csh too!
Even stranger, running
sh < /dev/tty > /dev/tty 2>/dev/tty
then running
ctest
fails! Now, by induction, init, or login, or something is going to have to have
redirected stdout to the terminal, at some time. Why should the last little
test have failed too?
If anyone from OSF is listening, can you tell me what curses is doing
in 'noecho', 'cbreak' and 'nonl' when stdout is redirected to stdout????
Can anyone explain this odd behaviour? Does the test fail to fail for
anyone?
In case anyone is wondering, WHY I want to redirect stdout to stdout, this is
simply a symptom of a different problem. I am porting a curses tool that
is used in a pipeline. stdin and stdout are passed as the pipeline, file
descriptor 3 is passed as the controlling terminal, and this must be dup'd
to stdout for the curses tool to use for the display (stdout having been
saved first for use in the pipeline).
It's kosher, it works on all other tested platforms. It's not like we are
trying to do anything wrong. It breaks on OSF1 (like so many other things :-()
Unfortunately, I'm not sure that I can simply use the BSD curses, as that is
a very old standard, and does not have some more advanced features that
the tool requires (but then even the SVSV curses is not fully SVR5 compatible
either :-()
Any help will be greatly appreciated
Glenn
--
Email - glenn@fs.com.au ,-_|\ glenn huxtable
phone - +61 9 328 8288 / \ functional software
fax - +61 9 328 8616 *_,-._/ PO box 192
v leederville WA 6903
next reply other threads:[~1995-01-26 11:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-01-26 11:02 Glenn Huxtable [this message]
1995-01-27 9:49 ` Odd curses bug - redirected stdout Glenn Huxtable
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox