diff --git a/inc/unixfork.h b/inc/unixfork.h index 945e530..5572baa 100644 --- a/inc/unixfork.h +++ b/inc/unixfork.h @@ -1,7 +1,2 @@ int fork_Unix(void); -#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 - diff --git a/src/unixcomm.c b/src/unixcomm.c index c3f3100..fc0deee 100644 --- a/src/unixcomm.c +++ b/src/unixcomm.c @@ -20,12 +20,6 @@ Unix Interface Communications #include "lispemul.h" - -/* FULLSLAVENAME => use a full file name for slave PTY */ -#ifdef OS5 -#define FULLSLAVENAME -#endif /* OS5 */ - #include #include #include /* JRB - timeout.h needs setjmp.h */ @@ -39,15 +33,8 @@ Unix Interface Communications #include #include #include -#include - - #include - -#ifdef sun -/* to get S_IFIFO defn for creating fifos */ -#include -#endif /* sun */ +#include #include "address.h" #include "adr68k.h" @@ -290,58 +277,31 @@ int FindUnixPipes(void) { /* F i n d A v a i l a b l e P t y */ /* */ /* Given strings Master and Slave, fill them with path names */ -/* of the forms: */ +/* to the master and slave psuedoterminals. */ /* */ -/* Master: /dev/ptyxx */ -/* Slave: /dev/ttyxx */ -/* */ -/* Which are the first available pty/tty pair for communicating */ -/* with a forked shell. */ -/* */ -/* Assumes that valid PTY names are [pqr][0-f]; if your system */ -/* is different, you'll need to change it. */ +/* This uses POSIX pseudoterminals. */ /* */ /************************************************************************/ -#define PTYLETTERS "pqr" -#define PTYNUMBERS "0123456789abcdef" - -/* Find the first PTY pair that is not in use */ - int FindAvailablePty(char *Master, char *Slave) { int res; char *let, *num; -#ifdef OS5 - res = open("/dev/ptmx", O_RDWR); + res = posix_openpt(O_RDWR); if (res < 0) { - perror("ptmx open"); + perror("open_pt failed"); return (-1); } grantpt(res); unlockpt(res); strcpy(Slave, ptsname(res)); DBPRINT(("slave pty name is %s.\n", Slave)); -#else - - /* From p to r */ - for (let = PTYLETTERS; *let != 0; let++) /* and 0 to f */ - for (num = PTYNUMBERS; *num != 0; num++) { - sprintf(Master, "/dev/pty%c%c", *let, *num); - sprintf(Slave, "%c%c", *let, *num); - DBPRINT(("Trying %s. ", Master)); - /* Try to open the Master side */ - res = open(Master, O_RDWR); -#endif if (res != -1) { fcntl(res, F_SETFL, fcntl(res, F_GETFL, 0) | O_NONBLOCK); return (res); } -#ifndef FULLSLAVENAME -} -#endif /* because we commented out the for above also... */ -return (-1); + return (-1); } /************************************************************************/ @@ -627,11 +587,9 @@ LispPTR Unix_handlecomm(LispPTR *args) { d[3] = slot; write(UnixPipeOut, d, 4); -#ifdef FULLSLAVENAME len = strlen(SlavePTY) + 1; write(UnixPipeOut, &len, 2); write(UnixPipeOut, SlavePTY, len); -#endif if (command != 4) { /* New style has arg1 = termtype, arg2 = command */ WriteLispStringToPipe(args[1]); diff --git a/src/unixfork.c b/src/unixfork.c index 8d9ea81..4a1ff17 100644 --- a/src/unixfork.c +++ b/src/unixfork.c @@ -36,7 +36,6 @@ #ifdef OS5 #include -#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");