ioctl TIOCSTI question

Ronald & sono!mayer at sun.com
Tue Mar 12 04:48:08 AEST 1991


On a sparcstation, SunOS 4.1 I am having a problem using the termio
ioctl TIOCSTI [simulate terminal input] when using gcc.  While it
works as expected under cc, under gcc I get an "Inappropriate ioctl
for device" error message.  Any ideas what I'm missing?

    Ron Mayer
    sun!sono!mayer     mayer at sono.uucp

[A (short) example program and OS/system info follows:]    


% cat ioc.c

/* This program works differently under gcc and cc. Why? */

#include <stdio.h>
#include <fcntl.h>
#include <sys/termios.h>
#include <errno.h>

main()
{
 char a;
 int fd=open("/dev/tty",O_RDWR);
 int ioctl_return;

 if (fd == -1) perror(NULL);

 a='l';
 ioctl(fd,TIOCSTI,&a);   /* should send characters as if typed to the tty*/
 a='s';
 ioctl(fd,TIOCSTI,&a);
 a='\n';
 ioctl_return = ioctl(fd,TIOCSTI,&a);

 if (ioctl_return == -1) perror(NULL);
}

%
% cc ioc.c
% a.out
ls
% ls                             [Note: The program "typed" this command]
a.out   ice.lst ioc.c   vhdl
%
%
% gcc ioc.c
% a.out
Inappropriate ioctl for device
%
%
%
% more /etc/motd
SunOS Release 4.1 (STANDALONE_1.2) #1: Wed Jul 25 00:05:22 PDT 1990
% arch -k
sun4c
%



More information about the Comp.unix.questions mailing list