ioctl problem in A/UX 2.0

Peter Espen pke@btr.com pke at public.BTR.COM
Sat Mar 9 04:12:11 AEST 1991


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);

}
/************************************************/

Thanks,

	Peter Espen
	pke at btr.com
	peter at sophia.com



More information about the Comp.unix.aux mailing list