C or ioctl help needed (SOLVED).

Richard A Downing richard at langside.org.uk
Sun Oct 9 13:42:37 PDT 2005


Richard A Downing wrote:

> Let's see what Felix Leitner has to say, before I start learning how to
> write C again (after 20 years off!).
> 
> Ken, thanks for the input, it's been instructive.


Well Felix von Leitner came through.  He says that the TIOCSCTTY ioctl
HAS to work otherwise there isn't a controlling tty and bash won't grant
job control.  He suggested the cvs version of fgetty which is coded
slightly differently, and this confirms and explains some of the
(previously mysterious to me, at least) google items I read yesterday.
Here's the relevant code:

  ...
  setsid();
  if ((fd=open(tty, O_RDWR, 0))<0)
    error("fgetty: could not open tty device\n",3);
  if (!isatty(fd))
    error("fgetty: \"not a typewriter\" ;-)\n",4);
  if (ioctl (fd, TIOCSCTTY, (void *)1)==0) {
    if (vhangup())	/* linux specific */
      error("fgetty: vhangup failed\n",5);
  } else...

Not a whole lot different, but this works fine.  Another happy customer
- me.

I'm quite impressed by Leitner's work - I just implemented his gatling
webserver.  http://www.fefe.de

Richard.



More information about the lfs-chat mailing list