ioctl problem in A/UX 2.0

Kent Sandvik ksand at Apple.COM
Sat Mar 9 11:52:10 AEST 1991


In article <2041 at public.BTR.COM> pke at public.BTR.COM (Peter Espen  pke at 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 <stdio.h>
>#include <termio.h>
>#include <fcntl.h>
>#include <sys/errno.h>
>
>
>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 at apple.com, AppleLink: KSAND  DISCLAIMER: Private mumbo-jumbo
Zippy++ says: "C++ was given to mankind, so that we might learn patience"



More information about the Comp.unix.aux mailing list