[comp.unix.wizards] terminal buffer...

hubcap@hubcap.UUCP (Mike Marshall) (03/02/88)

Hi -

here's a chunk of code from a program I once wrote... what is does is
send an x-off to a terminal. I was using it to store up unredirectable
stuff (like the output of mt, which is written directly to the controlling
terminal, not stdout) in the terminal's output buffer (where ever that is) 
so that I could throw it away (by using ioctl to cram a buffer-flush char 
into the output stream, prior to sending an x-on). That works great, but
now I wish my program could look at the stuff before I throw it away.

Does anyone know how I might be able to look at the stuff stored in the 
terminal's output buffer? I didn't see any ioctls
that would let me do that, but maybe I just didn't understand what the 
manual was telling me...

thanks...   
Mike Marshall    hubcap@hubcap.clemson.edu       ...!hubcap!hubcap

/*
 . send an XOFF to tty associated with this process...
 */
xoff(tty)
int tty;
{
  struct tchars t;

  /* get the terminal's special character set... */
  if (ioctl(tty,(int)TIOCGETC,(char *)&t) == -1) {
     puts("ratmaw: unable to determine tty special chars. goodbye.");
     exit(-1);
  }
  /* send the XOFF... */
  if (ioctl(tty,(int)TIOCSTI,(char *)&t.t_stopc) == -1) {
     puts("ratmaw: unable to XOFF. goodbye.");
     exit(-1);
  }
}