[comp.sys.next] pseudo-terminal programming question

garnett@cs.utexas.edu (John William Garnett) (06/23/91)

I wish to use the pseudoterminal interface on the NeXT (e.g. /dev/ptyqa
and /dev/ttyqa).  I notice that Terminal uses pty's [when I type
the who command, the terminal is listed as ttyp8 which is the slave
side of a pty].

My question (#1) is:  how can my application [which is written in C]
choose a pty that isn't currently being used? I don't wish to use an
arbitrary /dev/pty?? file because then I risk writing into a running
Terminal window.  Is there some locks directory or other reservation
system for pty's?

Question #2: once I have selected a pty that isn't being used,
how do I reserve that pty so that some other application (possibly
my own) doesn't attempt to use the pty (assuming that other application
uses the answer to question #1 to check if the pty is in use).

Responses via email are best.  I'll summarize if anyone expresses
interest in the answers.

Thanks.
-- 
John Garnett
                              University of Texas at Austin
garnett@cs.utexas.edu         Department of Computer Science
                              Austin, Texas