[comp.unix.aux] Bug in console emulator

fnf@fishpond.UUCP (Fred Fish) (08/20/88)

The following demonstrates what looks like a problem with the
"A/UX Initial Console Emulator".  Can anyone suggest any workarounds?
Thanks.
-Fred

----------------------------------------------------------------------
Script started on Fri Aug 19 12:50:04 1988
fishpond:222> cat bug.c
#include <stdio.h>

main ()
{
        extern char *ttyname ();
        extern int isatty ();

        printf ("isatty (stdin) = %d\n", isatty (stdin));
        printf ("isatty (stdout) = %d\n", isatty (stdout));
        printf ("isatty (stderr) = %d\n", isatty (stderr));
        printf ("ttyname (stdin) = %s\n", ttyname (stdin));
        printf ("ttyname (stdout) = %s\n", ttyname (stdout));
        printf ("ttyname (stderr) = %s\n", ttyname (stderr));
}

fishpond:223> cc bug.c
fishpond:224> a.out
isatty (stdin) = 0
isatty (stdout) = 0
isatty (stderr) = 0
ttyname (stdin) = P
ttyname (stdout) = P
ttyname (stderr) = P
fishpond:225> exit

script done on Fri Aug 19 12:50:27 1988
----------------------------------------------------------------------
-- 
# Fred Fish, 1346 West 10th Place, Tempe, AZ 85281,  USA
# noao!nud!fishpond!fnf                   (602) 921-1113

dwb@Apple.COM (David W. Berry) (08/23/88)

In article <121@fishpond.UUCP> fnf@fishpond.UUCP (Fred Fish) writes:
>The following demonstrates what looks like a problem with the
>"A/UX Initial Console Emulator".  Can anyone suggest any workarounds?
>Thanks.
>-Fred
	Nope, I'd say it looks like a problem with your test
program.  isatty and ttyname both work on a file descriptor
and your passing it a FILE structure.  Try replacing stdin with
fileno(stdin) and similar for stdout and stderr and you'll get
what you expect.
>
>----------------------------------------------------------------------
>Script started on Fri Aug 19 12:50:04 1988
>fishpond:222> cat bug.c
>#include <stdio.h>
>
>main ()
>{
>        extern char *ttyname ();
>        extern int isatty ();
>
>        printf ("isatty (stdin) = %d\n", isatty (stdin));
>        printf ("isatty (stdout) = %d\n", isatty (stdout));
>        printf ("isatty (stderr) = %d\n", isatty (stderr));
>        printf ("ttyname (stdin) = %s\n", ttyname (stdin));
>        printf ("ttyname (stdout) = %s\n", ttyname (stdout));
>        printf ("ttyname (stderr) = %s\n", ttyname (stderr));
>}


Opinions:  MINE, ALL MINE! (greedy evil chuckle)

David W. Berry
apple!dwb@sun.com	dwb@apple.com	973-5168@408.MaBell

fnf@fishpond.UUCP (Fred Fish) (08/23/88)

In article <15956@apple.Apple.COM> dwb@apple.com.UUCP (David W. Berry) writes:
+In article <121@fishpond.UUCP> fnf@fishpond.UUCP (Fred Fish) writes:
++The following demonstrates what looks like a problem with the
++"A/UX Initial Console Emulator".  Can anyone suggest any workarounds?
+	Nope, I'd say it looks like a problem with your test
+program.  isatty and ttyname both work on a file descriptor
+and your passing it a FILE structure.  Try replacing stdin with
+fileno(stdin) and similar for stdout and stderr and you'll get
+what you expect.

Yes, I received mail from several people pointing out my boo-boo
(thanks everyone!).  Guess that will teach me to look in the manual
after I haven't used a function for a while.

-Fred
-- 
# Fred Fish, 1346 West 10th Place, Tempe, AZ 85281,  USA
# noao!nud!fishpond!fnf                   (602) 921-1113