From: meissner@osf.org (Michael Meissner)
Subject: Re: /dev/ptm
Date: Thu, 31 Dec 1992 03:28:44 GMT [thread overview]
Message-ID: <MEISSNER.92Dec30222841@curley.osf.org> (raw)
In-Reply-To: rince@dcs.warwick.ac.uk's message of 22 Dec 92 09:14:37 GMT
In article <1992Dec22.091437.11429@dcs.warwick.ac.uk> rince@dcs.warwick.ac.uk (James Bonfield) writes:
| Hello,
| Why does the 'script' command allocate itself a new controlling tty
| and yet no other 'standard' (eg emacs, fep) program seem able to? I've read
| the manuals for other machines and written programs to grab themselves a new
| tty by dissociating, becoming a session leader, and opening a terminal that
| current has no controlling process.
|
| This works on all machines I've tried except an Alpha running OSF1. By
| debugging script a bit I figured out it opens (read-write) /dev/ptm. This is
| not in any of the online manuals as far as I can see, and neither is how to
| become the controlling process. Can anyone offer assistance here?
While I can only speak for the OSF/1 that we ship to the licensees,
and not what gets shiped ultimately to customers, the openpty and
forkpty functions will open pty's for you. Revision 1.0.x of OSF/1
from us had the functions in libutil.a. Revision 1.[12].x of OSF/1
moved the functions to libc.a. In revision 1.0 the manual did not
cover these functions, an oversight which was fixed in 1.1.
The file /dev/ptm that you mention is a streams clone device that when
opened gives you the file descriptor to the master end. You get the
slave file descriptor by taking the minor device number of the master
fd, converting it to ascii, and prepending '/dev/pts/' to it, and
opening that filename.
NAME
openpty, forkpty - Opens a pseudoterminal master and slave
device-pair
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
int openpty(
int *amaster,
int *aslave,
char *name,
struct termios *termp,
struct winsize *winp);
int forkpty(
int *amaster,
char *name,
struct termios *termp,
struct winsize *winp);
PARAMETERS
amaster Points to the file descriptor of the master pty,
typically /dev/ptmx_bsd.
aslave Points to the file descriptor of a slave pty,
/dev/pty/N.
name Contains the name returned name of the slave pty
that was opened, or a null pointer if the open was
not successful.
termp Points to the termios structure containing the
terminal attributes for the opened slave pty.
winp Points to the winsize structure containing the
window attributes for the opened slave pty.
DESCRIPTION
The openpty() function opens a master and slave device-pair
for a pseudoterminal, and sets the terminal attributes for
the slave device according to the specifications in the term
and winp parameters. This function invokes the pty_master()
and pty_slave() functions to perform the opening of the mas-
ter and slave devices. If either of these functions return
[ENOENT] indicating failure due to a lack of available ptys,
the sysconfig command should be used to increase the limit
on these type devices in the system.
The forkpty() function allocates and invokes a child process
for a pseudoterminal. It sets the child process's pty ter-
minal attributes according to the specifications in the term
and winp parameters.
RETURN VALUES
Upon successful completion, the openpty() function returns a
value of 0 (zero). Otherwise, it returns a value of -1. The
forkpty() function returns a value of 0 (zero) to the child
process, and returns the process ID of the child process to
the parent process on success. However, on error, this
function returns a value of -1 to the parent process, and
does not create a child process.
ERRORS
If any of the following conditions occurs, the openpty()
function sets errno to the corresponding value:
[ENXIO] Unable to locate the specified pty.
[ENOENT] There are no more ptys that can be opened.
RELATED INFORMATION
Commands: sysconfig(8).
Functions: pty_master, pty_slave.
--
Michael Meissner email: meissner@osf.org phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
You are in a twisty little passage of standards, all conflicting.
prev parent reply other threads:[~1992-12-31 3:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1992Dec22.091437.11429@dcs.warwick.ac.uk>
1992-12-22 19:02 ` /dev/ptm Rich Salz
1992-12-31 3:28 ` Michael Meissner [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox