Path: utzoo!news-server.csri.toronto.edu!rutgers!apple!ksand From: ksand@Apple.COM (Kent Sandvik) Newsgroups: comp.unix.aux Subject: Re: ioctl problem in A/UX 2.0 Keywords: AUX, 2.0, ioctl, help Message-ID: <50032@apple.Apple.COM> Date: 9 Mar 91 01:52:10 GMT References: <2041@public.BTR.COM> Distribution: usa Organization: Apple Computer Inc., Cupertino, CA Lines: 82 In article <2041@public.BTR.COM> pke@public.BTR.COM (Peter Espen pke@btr.com) writes: > >Can someone explain to me why the first ioctl call in the following test >program fails with an invalid argument error? > >I am running A/UX 2.0. > > >/***********************************************/ >#define _SYSV_SOURCE > >#include >#include >#include >#include > > >extern int errno; >int fp; > >char *c_on = "TEST OUTPUT"; >char *name = "/dev/tty0"; > >main () >{ > ttyout ( ); >} > >ttyout( ) >{ > int i, tt; > > struct termio my_termio; > char *buf; > > if ((fp = open( name, O_RDWR | O_NDELAY)) == NULL) { > printf("error opening /dev/tty0"); > exit(0); > } > > > if ( (i = ioctl( fp, TCGETA, &my_termio)) < 0) { > perror("TCGETA:"); > fprintf(stderr, "%d: ioctl error on TCGETA op. \n", errno); > exit(0); > } > > my_termio.c_cflag |= B9600; > > if ( (i = ioctl( fp, TCSETA, &my_termio)) < 0) { > fprintf(stderr, "ioctl error on TCSETA operation. \n"); > exit(0); > } > > buf = c_on; > > if (fputs(buf, fp) == NULL) > fprintf(stderr, "can't fprintf to %s\n", name); > else > return; > >close(fp); > >} >/************************************************/ Hmmm, I did a quick test on my 2.0.1 system sitting behind my back, and it did not bang out with the first ioctl call, neither the second. Sometimes ioctl and open on tty1, i.e. the printer port, fails because Localtalk/AppleTalk is operating on that port (default setting). Anyway, maybe someone else has an explanation, or this is gone in A/UX 2.0.1. regards, Kent Sandvik -- Kent Sandvik, Apple Computer Inc, Developer Technical Support NET:ksand@apple.com, AppleLink: KSAND DISCLAIMER: Private mumbo-jumbo Zippy++ says: "C++ was given to mankind, so that we might learn patience"