1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-31 22:02:33 +00:00

Switch to using POSIX pseudoterminals.

Previously, we were using SysV pseudo-terminals on Solaris and BSD
pseudo-terminals on other Unix platforms. BSD pseudo-terminals have
been deprecated on Linux and are no longer available in some kernel
configurations.

The POSIX API is basically the same as the SysV API, apart from using
`posix_openpt` instead of `open` with `/dev/ptmx`.

Closes interlisp/medley#121.
This commit is contained in:
Bruce Mitchener
2021-01-02 12:51:14 +07:00
parent 67d6a799db
commit a271917a61
3 changed files with 7 additions and 71 deletions

View File

@@ -36,7 +36,6 @@
#ifdef OS5
#include <sys/stropts.h>
#define FULLSLAVENAME
#endif
#include "dbprint.h"
@@ -81,15 +80,8 @@ loop:
/* Creates a PTY connection to a csh */
#ifdef FULLSLAVENAME
int ForkUnixShell(int slot, char *PtySlave, char *termtype, char *shellarg)
#else
int ForkUnixShell(int slot, char ltr, char numb, char *termtype, char *shellarg)
#endif
{
#ifndef FULLSLAVENAME
char PtySlave[20];
#endif
int res, PID, SlaveFD;
struct termios tio;
@@ -103,9 +95,6 @@ int ForkUnixShell(int slot, char ltr, char numb, char *termtype, char *shellarg)
perror("setsid");
/* Open the slave side */
#ifndef FULLSLAVENAME
sprintf(PtySlave, "/dev/tty%c%c", ltr, numb);
#endif
SlaveFD = open(PtySlave, O_RDWR);
if (SlaveFD == -1) {
perror("Slave Open");
@@ -304,12 +293,10 @@ int fork_Unix() {
case 'P': /* Fork PTY shell */
if (slot >= 0) { /* Found a free slot */
char termtype[32];
#ifdef FULLSLAVENAME
char slavepty[32]; /* For slave pty name */
if (SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading slave pty len");
if (SAFEREAD(LispPipeIn, slavepty, tmp) < 0) perror("Slave reading slave pty id");
#endif /* FULLSLAVENAME */
if (IOBuf[0] == 'P') { /* The new style, which takes term type & command to csh */
if (SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading cmd length");
@@ -328,12 +315,8 @@ int fork_Unix() {
cmdstring[0] = 0;
}
/* Alloc a PTY and fork */
#ifdef FULLSLAVENAME
/* Alloc a PTY and fork */
pid = ForkUnixShell(slot, slavepty, termtype, cmdstring);
#else
pid = ForkUnixShell(slot, IOBuf[1], IOBuf[2], termtype, cmdstring);
#endif
if (pid == -1) {
printf("Impossible failure from ForkUnixShell??\n");