mirror of
https://github.com/Interlisp/maiko.git
synced 2026-04-18 08:26:02 +00:00
Compare commits
2 Commits
maiko-2110
...
maiko-2110
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75c668f1cd | ||
|
|
a25368714f |
@@ -31,7 +31,6 @@
|
|||||||
#include "lispemul.h" /* for LispPTR, DLword */
|
#include "lispemul.h" /* for LispPTR, DLword */
|
||||||
#include "miscstat.h" /* for MISCSTAT */
|
#include "miscstat.h" /* for MISCSTAT */
|
||||||
|
|
||||||
extern DLword *Atomspace; /* ATOMSPACE */
|
|
||||||
extern DLword *Stackspace; /* STACKSPACE*/
|
extern DLword *Stackspace; /* STACKSPACE*/
|
||||||
extern DLword *Plistspace; /* PLISTSPACE */
|
extern DLword *Plistspace; /* PLISTSPACE */
|
||||||
extern DLword *DTDspace; /* DTDSPACE */
|
extern DLword *DTDspace; /* DTDSPACE */
|
||||||
@@ -41,8 +40,6 @@
|
|||||||
extern DLword *AtomSpace; /* New atoms, initial set */
|
extern DLword *AtomSpace; /* New atoms, initial set */
|
||||||
extern DLword *Defspace; /* DEFSPACE */
|
extern DLword *Defspace; /* DEFSPACE */
|
||||||
extern DLword *Valspace; /* VALSPACE */
|
extern DLword *Valspace; /* VALSPACE */
|
||||||
extern DLword *Spospspace; /* POSITIVE Smallp */
|
|
||||||
extern DLword *Snegspace; /* NEGATIVE Smallp */
|
|
||||||
|
|
||||||
/* For Virtual Mem Management */
|
/* For Virtual Mem Management */
|
||||||
#ifdef BIGVM
|
#ifdef BIGVM
|
||||||
@@ -82,7 +79,6 @@ extern DLword *UFNTable ;
|
|||||||
|
|
||||||
|
|
||||||
/* FLEX STORAGES */
|
/* FLEX STORAGES */
|
||||||
extern DLword *Arrayspace; /* Start of ARRAYSPACE */
|
|
||||||
extern DLword *MDS_space_bottom; /* Start of MDS (pre -2) */
|
extern DLword *MDS_space_bottom; /* Start of MDS (pre -2) */
|
||||||
extern DLword *PnCharspace ; /* Space for PN char codes (Thin only) */
|
extern DLword *PnCharspace ; /* Space for PN char codes (Thin only) */
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,6 @@
|
|||||||
DLword *Lisp_world; /* lispworld */
|
DLword *Lisp_world; /* lispworld */
|
||||||
|
|
||||||
/********** 68k address for Lisp Space **********/
|
/********** 68k address for Lisp Space **********/
|
||||||
DLword *Atomspace;
|
|
||||||
DLword *Stackspace;
|
DLword *Stackspace;
|
||||||
DLword *Plistspace;
|
DLword *Plistspace;
|
||||||
DLword *DTDspace;
|
DLword *DTDspace;
|
||||||
@@ -85,8 +84,6 @@ DLword *Pnamespace;
|
|||||||
DLword *AtomSpace;
|
DLword *AtomSpace;
|
||||||
DLword *Defspace;
|
DLword *Defspace;
|
||||||
DLword *Valspace;
|
DLword *Valspace;
|
||||||
DLword *Spospspace;
|
|
||||||
DLword *Snegspace;
|
|
||||||
|
|
||||||
/********** For Virtual Memory Management **********/
|
/********** For Virtual Memory Management **********/
|
||||||
#ifdef BIGVM
|
#ifdef BIGVM
|
||||||
@@ -124,7 +121,6 @@ DLword *HTcoll;
|
|||||||
DLword *DisplayRegion;
|
DLword *DisplayRegion;
|
||||||
int DisplayInitialized = NIL;
|
int DisplayInitialized = NIL;
|
||||||
|
|
||||||
DLword *Arrayspace;
|
|
||||||
DLword *MDS_space_bottom;
|
DLword *MDS_space_bottom;
|
||||||
DLword *PnCharspace;
|
DLword *PnCharspace;
|
||||||
struct dtd *ListpDTD;
|
struct dtd *ListpDTD;
|
||||||
|
|||||||
@@ -267,7 +267,6 @@ LispPTR compare_lisp_chars(register const char *char1, register const char *char
|
|||||||
LispPTR make_atom(const char *char_base, DLword offset, DLword length, short int non_numericp)
|
LispPTR make_atom(const char *char_base, DLword offset, DLword length, short int non_numericp)
|
||||||
/* if it is NIL then these chars are treated as NUMBER */
|
/* if it is NIL then these chars are treated as NUMBER */
|
||||||
{
|
{
|
||||||
extern DLword *Spospspace;
|
|
||||||
extern DLword *AtomHT;
|
extern DLword *AtomHT;
|
||||||
extern DLword *Pnamespace;
|
extern DLword *Pnamespace;
|
||||||
extern DLword *AtomSpace;
|
extern DLword *AtomSpace;
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ static int FindAvailablePty(char *Slave) {
|
|||||||
/* => byte count (<= 512), NIL (no data), or T (EOF) */
|
/* => byte count (<= 512), NIL (no data), or T (EOF) */
|
||||||
/* 10 Set Window Size, Arg2 = rows, Arg3 = columns */
|
/* 10 Set Window Size, Arg2 = rows, Arg3 = columns */
|
||||||
/* 11 Fork PTY to Shell (obsoletes command 4) */
|
/* 11 Fork PTY to Shell (obsoletes command 4) */
|
||||||
/* Arg1 = termtype, Arg2 = csh command string */
|
/* Arg1 = termtype, Arg2 = shell command string */
|
||||||
/* => Job # or NIL */
|
/* => Job # or NIL */
|
||||||
/* 12 Create Unix Socket */
|
/* 12 Create Unix Socket */
|
||||||
/* Arg1 = pathname to bind socket to (string) */
|
/* Arg1 = pathname to bind socket to (string) */
|
||||||
|
|||||||
118
src/unixfork.c
118
src/unixfork.c
@@ -75,76 +75,78 @@ static inline ssize_t SAFEREAD(int f, char *b, int c)
|
|||||||
/* */
|
/* */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
/* Creates a PTY connection to a csh */
|
/* Creates a PTY connection to a shell */
|
||||||
|
|
||||||
static int ForkUnixShell(int slot, char *PtySlave, char *termtype, char *shellarg)
|
static int ForkUnixShell(int slot, char *PtySlave, char *termtype, char *shellarg)
|
||||||
{
|
{
|
||||||
int PID, SlaveFD;
|
int PID, SlaveFD;
|
||||||
struct termios tio;
|
struct termios tio;
|
||||||
|
char *argvec[4] = {NULL, NULL, NULL, NULL};
|
||||||
|
char *shell = NULL;
|
||||||
|
char *userShell = NULL;
|
||||||
|
|
||||||
PID = fork();
|
PID = fork();
|
||||||
|
|
||||||
if (PID == 0) {
|
if (PID != 0) {
|
||||||
char *argvec[4];
|
|
||||||
|
|
||||||
if (0 > setsid()) /* create us a new session for tty purposes */
|
|
||||||
perror("setsid");
|
|
||||||
|
|
||||||
/* Open the slave side */
|
|
||||||
SlaveFD = open(PtySlave, O_RDWR);
|
|
||||||
if (SlaveFD == -1) {
|
|
||||||
perror("Slave Open");
|
|
||||||
perror(PtySlave);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef OS5
|
|
||||||
ioctl(SlaveFD, I_PUSH, "ptem");
|
|
||||||
ioctl(SlaveFD, I_PUSH, "ldterm");
|
|
||||||
#endif /* OS5 */
|
|
||||||
|
|
||||||
/* Set up as basic display terminal: canonical erase,
|
|
||||||
kill processing, echo, backspace to erase, echo ctrl
|
|
||||||
chars as ^x, kill line by backspacing */
|
|
||||||
tcgetattr(SlaveFD, &tio);
|
|
||||||
tio.c_lflag |= ICANON | ECHO | ECHOE | ECHOCTL | ECHOKE;
|
|
||||||
tcsetattr(SlaveFD, TCSANOW, &tio);
|
|
||||||
|
|
||||||
(void)dup2(SlaveFD, 0);
|
|
||||||
(void)dup2(SlaveFD, 1);
|
|
||||||
(void)dup2(SlaveFD, 2);
|
|
||||||
(void)close(SlaveFD);
|
|
||||||
|
|
||||||
/* set the LDESHELL variable so the underlying .cshrc can see it and
|
|
||||||
configure the shell appropriately, though this may not be so important any more */
|
|
||||||
setenv("LDESHELL", "YES", 1);
|
|
||||||
|
|
||||||
if (termtype[0] != 0) { /* set the TERM environment var */
|
|
||||||
setenv("TERM", termtype, 1);
|
|
||||||
}
|
|
||||||
/* Start up csh */
|
|
||||||
argvec[0] = "csh";
|
|
||||||
if (shellarg[0] != 0) { /* setup to run command */
|
|
||||||
argvec[1] = "-c"; /* read commands from next arg */
|
|
||||||
argvec[2] = shellarg;
|
|
||||||
argvec[3] = (char *)0;
|
|
||||||
} else
|
|
||||||
argvec[1] = (char *)0;
|
|
||||||
|
|
||||||
execv("/bin/csh", argvec);
|
|
||||||
|
|
||||||
/* Should never get here */
|
|
||||||
perror("execv");
|
|
||||||
exit(0);
|
|
||||||
} else { /* not the forked process. */
|
|
||||||
if (shellarg != shcom) free(shellarg);
|
if (shellarg != shcom) free(shellarg);
|
||||||
|
return (PID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the process group so all the kids get the bullet too
|
if (0 > setsid()) /* create us a new session for tty purposes */
|
||||||
if (setpgrp(PID, PID) != 0)
|
perror("setsid");
|
||||||
perror("setpgrp"); */
|
|
||||||
|
|
||||||
return (PID);
|
/* Open the slave side */
|
||||||
|
SlaveFD = open(PtySlave, O_RDWR);
|
||||||
|
if (SlaveFD == -1) {
|
||||||
|
perror("Slave Open");
|
||||||
|
perror(PtySlave);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef OS5
|
||||||
|
ioctl(SlaveFD, I_PUSH, "ptem");
|
||||||
|
ioctl(SlaveFD, I_PUSH, "ldterm");
|
||||||
|
#endif /* OS5 */
|
||||||
|
|
||||||
|
/* Set up as basic display terminal: canonical erase,
|
||||||
|
kill processing, echo, backspace to erase, echo ctrl
|
||||||
|
chars as ^x, kill line by backspacing */
|
||||||
|
tcgetattr(SlaveFD, &tio);
|
||||||
|
tio.c_lflag |= ICANON | ECHO | ECHOE | ECHOCTL | ECHOKE;
|
||||||
|
tcsetattr(SlaveFD, TCSANOW, &tio);
|
||||||
|
|
||||||
|
(void)dup2(SlaveFD, 0);
|
||||||
|
(void)dup2(SlaveFD, 1);
|
||||||
|
(void)dup2(SlaveFD, 2);
|
||||||
|
(void)close(SlaveFD);
|
||||||
|
|
||||||
|
/* set the LDESHELL variable so the underlying shell initialization can see it and
|
||||||
|
configure the shell appropriately, though this may not be so important any more */
|
||||||
|
setenv("LDESHELL", "YES", 1);
|
||||||
|
|
||||||
|
if (termtype[0] != 0) { /* set the TERM environment var */
|
||||||
|
setenv("TERM", termtype, 1);
|
||||||
|
}
|
||||||
|
/* Start up shell -- use SHELL environment variable as long as it's in /etc/shells */
|
||||||
|
shell = getenv("SHELL");
|
||||||
|
for (userShell = getusershell(); userShell != NULL && strcmp(shell, userShell) != 0; userShell = getusershell());
|
||||||
|
if (userShell == NULL) {
|
||||||
|
perror("$(SHELL) not found in /etc/shells");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* argvec entries initialized to NULL */
|
||||||
|
argvec[0] = strrchr(userShell, '/') + 1;
|
||||||
|
if (shellarg[0] != 0) { /* setup to run command */
|
||||||
|
argvec[1] = "-c"; /* read commands from next arg */
|
||||||
|
argvec[2] = shellarg;
|
||||||
|
}
|
||||||
|
|
||||||
|
execv(userShell, argvec);
|
||||||
|
|
||||||
|
/* Should never get here */
|
||||||
|
perror("execv");
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fork_Unix is the secondary process spawned right after LISP is
|
/* fork_Unix is the secondary process spawned right after LISP is
|
||||||
|
|||||||
Reference in New Issue
Block a user