C or ioctl help needed.

Ken Moffat zarniwhoop at ntlworld.com
Sat Oct 8 16:08:36 PDT 2005

On Sat, 8 Oct 2005, Richard A Downing wrote:

> I'm trying to debug fgetty.  It's a replacement for getty using dietlibc.
> Now it's supposed to run if called like this:
> fgetty /dev/tty3
> But this fails for me.  The relevant code is:
> if ((fd=open(tty, O_RDWR, 0))<0 || ioctl (fd, TIOCSCTTY, (void *1)==-1)
>    error("could not open tty device\n",3);
> and this always fails (despite any perms, mine are 666 of /dev/tty3).
> The open is OK, it's the ioctl condition that's failing.  But I'm damned
> if I know where to look for what this is doing.
> Any ideas?  Google has revealed zilch.

  Lots of hits for TIOCSCTTY !  It's trying to set the controlling tty.
I've no idea how to find the code in the kernel (finding the define of 
the ioctl is easy enough, but I don't know how this is translated to a 

  Maybe this url might provide some ideas.  Sounds as if you have to be 
root, AND the current process must not have a controlling tty (which 
will be interesting to debug, if true).


  You might want to try ignoring the error (google found some ssh code 
for sparc which ignores the return value from TIOCSCTTY because HP 
returns EINVAL ! ).

  das eine Mal als Tragödie, das andere Mal als Farce

More information about the lfs-chat mailing list