From: neill_clift@hicom.lut.ac.uk
Subject: Re: Connecting FTA to VTA
Reply-To: neill_clift@hicom.lut.ac.uk
Organization: Hicom Sevices
Date: Thu, 20 Aug 92 05:19:31 GMT

In article <1992Aug19.125754.1851@cs.rose-hulman.edu>, mgrthh@HYDRA.ROSE-HULMAN.EDU writes:
>
>   I am writing an application that uses pseudoterminals (the new, FTA kind)
>   as the input/output device of an interactive process.  This process is
>   created with $CREPRC, with the flags PRC$V_INTER, PRC$V_DETACH, and
>   PRC$V_NOPASSWORD, executing LOGINOUT, so that an interactive process is
>   created without having to enter a username and password.  This happens
>   fine.
>
>   What I want to do is have a virtual terminal (VTA) device be connected to
>   the pseudoterminal, so that the interactive process can become
>   disconnected from the pseudoterminal.  Virtual terminals are already set
>   up correctly on the system, and the pseudoterminal is being created with
>   the TT2$V_DISCONNECT bit set.
>
Funny you should ask this as I have just done this at home! I am working on a
program to place a detached process under debug. The code works by creating a
pseudo-terminal and attaching a virtual terminal to it. This terminal name is
then sent to the detached process via an AST where DBG$INPUT etc are defined to
point to the virtual terminals. After that my program can ship user commands to
the detached process. When you want to continue the program just disconnects
the physical from the virtual terminal. If you want to come back to debug at
some later time the program can just connect back up to the virtual terminals.

One very interesting thing I discovered when writing the reconnect code was
that reconnects only occur when the last channel is deassigned from the
terminal (ref count goes to zero). Since FTAnnn: devices are created with zero
reference counts in order to do the reconnect I had to assign another channel
and deassign it straight after.
>
>   What happens: If I do not create the process (but rather simply create
>   the pseudoterminal), input to the pseudoterminal will cause the job
>   controller (I believe) to create a virtual terminal, attach the
>   pseudoterminal to the virtual terminal, and create a process running
>   LOGINOUT.
It took me a bit to find out where virtual terminals are created. Its not done
by the job controler explicitly. Its done by TTDRIVER when unsolicited input is
entered on a terminal with a reference count of zero. Look at TTYSUB in
TTDRIVER. The routine is called UNSOL or something like that.

>
>   The question: How do I do what the job controller (apparently) is
>   doing--how do I create the VTA device and connect the "physical" FTA
>   device to it?
I dont have the code here as I am working on this program on my own VAX in my
own time at home. If you want it its yours. Be warned! Its kernel, its macro,
its complicated, its unsupported and it will probably break in the future.
>
>   Thanks for any help that anyone can provide!
>
>                                                        - Tom
>
>--
>Thomas H. Hopson                                mgrthh@rosevc.rose-hulman.edu 
>VMS System Manager                              mgrthh@rhit.bitnet
>Rose-Hulman Institute of Technology             
>Terre Haute, Indiana                  NeXTmail: mgrthh@nextwork.rose-hulman.edu

Good luck.
                                 Neill.
Xref: sparky comp.os.vms:13569 vmsnet.sources.d:533