I was trying to write a gopher mole, which is essentially a UNIX daemon, on NetBSD. The interpreter wouldn't initialise because tcgetattr returned an error other than ENOTTY.
The following patch fixes this:
--- keyboard.c.orig 2012-12-28 22:12:15.000000000 +0000
+++ keyboard.c 2012-12-17 00:05:29.000000000 +0000
@@ -1531,7 +1531,7 @@
keyboard = fileno(stdin);
errcode = tcgetattr(keyboard, &tty);
if (errcode < 0) { /* Could not obtain keyboard parameters */
- if (errno != ENOTTY) return FALSE; /* tcgetattr() returned an error we cannot handle */
+ if (errno != ENOTTY && errno != EOPNOTSUPP) return FALSE; /* tcgetattr() returned an error we cannot handle */
/*
** The error returned by tcgetattr() was ENOTTY (not a typewriter).
** This says that stdin is not associated with a keyboard. The
Darren,
I can't accept your patch as it stands.
The EOPNOTSUPP errorcode means "Operation not supported on transport endpoint", this doesn't much sound like a tty related error.
Please investigate further, if this is some quirky behaviour of NetBSD then please wrap the change in an #ifdef NetBSD so that the behaviour on other systems remains the same.
Colin
No response from submitter for more info - so closing.