Messages in this thread | | | Date | Fri, 9 Jan 1998 18:58:32 +0100 | From | "Mark M._Kettenis" <> | Subject | Pseudo-terminals (was devfs) |
| |
In response to the various messages about a new implementation of pseudo-terminals in the Linux, here is some info about the relation between pseudo-terminals and the Unix98 specification.
The Unix98 specification contains three functions dealing exculisively with pseudo-terminals:
int grantpt (int FILEDES); int unlockpt (int FILEDES); char *ptsname (int FILEDES);
The grantpt() function is supposed the mode and ownership of the slave pseudo-terminal associated with master FILEDES. The user ID should be set to the real UID of the calling process, the group ID to some unspecified group (tty?). The permission mode should be set to 0620.
On Solaris 2.5 this is done by calling a setuid program, which is allowed by the specification. It seems that on AIX 4.2 it is done directly in the kernel.
The unlockpt() function is supposed to "unlock" the pseudo-terminal associated with FILEDES.
The specification says that portable applications must call unlockpt before openening the slave side of a pseudo-terminal device. This suggests that it may very well be a no-op, in case no locking is needed.
The ptsname() function returns a pointer to a string wich is the name of the slave pseudo-terminal associated with master FILEDES.
Typical usage would be something like
int master, slave;
master = open ("/dev/ptmx", ...); grantpt (master); unlockpt (master); slave = open (ptsname (master), ...);
/* Do some usefull things on the pseudo-terminal. */
The name "/dev/ptmx" seems to be the standard, so I suggest to stick with that. The standard names for the slave devices are "/dev/pts/N".
Since these three functions are three of the few remaining Unix98 functions that have not yet been implemented in glibc it would be nice if an upcoming reimplementation of pseudo-terminals in the kernel would provide us with the means to implement these functions.
Mark
| |