OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [expect/] [pty_termios.c] - Diff between revs 578 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 578 Rev 1765
/* pty_termios.c - routines to allocate ptys - termios version
/* pty_termios.c - routines to allocate ptys - termios version
 
 
Written by: Don Libes, NIST, 2/6/90
Written by: Don Libes, NIST, 2/6/90
 
 
This file is in the public domain.  However, the author and NIST
This file is in the public domain.  However, the author and NIST
would appreciate credit if you use this file or parts of it.
would appreciate credit if you use this file or parts of it.
 
 
*/
*/
 
 
/* Must be first, so that _XOPEN_SOURCE works.  */
/* Must be first, so that _XOPEN_SOURCE works.  */
#include "expect_cf.h"
#include "expect_cf.h"
 
 
#include <stdio.h>
#include <stdio.h>
#include <signal.h>
#include <signal.h>
 
 
#if defined(SIGCLD) && !defined(SIGCHLD)
#if defined(SIGCLD) && !defined(SIGCHLD)
#define SIGCHLD SIGCLD
#define SIGCHLD SIGCLD
#endif
#endif
 
 
/*
/*
   The following functions are linked from the Tcl library.  They
   The following functions are linked from the Tcl library.  They
   don't cause anything else in the library to be dragged in, so it
   don't cause anything else in the library to be dragged in, so it
   shouldn't cause any problems (e.g., bloat).
   shouldn't cause any problems (e.g., bloat).
 
 
   The functions are relatively small but painful enough that I don't care
   The functions are relatively small but painful enough that I don't care
   to recode them.  You may, if you absolutely want to get rid of any
   to recode them.  You may, if you absolutely want to get rid of any
   vestiges of Tcl.
   vestiges of Tcl.
*/
*/
extern char *TclGetRegError();
extern char *TclGetRegError();
 
 
 
 
 
 
#if defined(HAVE_PTYM) && defined(HAVE_PTMX)
#if defined(HAVE_PTYM) && defined(HAVE_PTMX)
/*
/*
 * HP-UX 10.0 with streams (optional) have both PTMX and PTYM.  I don't
 * HP-UX 10.0 with streams (optional) have both PTMX and PTYM.  I don't
 * know which is preferred but seeing as how the HP trap stuff is so
 * know which is preferred but seeing as how the HP trap stuff is so
 * unusual, it is probably safer to stick with the native HP pty support,
 * unusual, it is probably safer to stick with the native HP pty support,
 * too.
 * too.
 */
 */
#undef HAVE_PTMX
#undef HAVE_PTMX
#endif
#endif
 
 
#ifdef HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#  include <unistd.h>
#  include <unistd.h>
#endif
#endif
#ifdef HAVE_INTTYPES_H
#ifdef HAVE_INTTYPES_H
#  include <inttypes.h>
#  include <inttypes.h>
#endif
#endif
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
 
 
#ifdef NO_STDLIB_H
#ifdef NO_STDLIB_H
#include "../compat/stdlib.h"
#include "../compat/stdlib.h"
#else
#else
#include <stdlib.h>
#include <stdlib.h>
#endif
#endif
 
 
#ifdef HAVE_SYSMACROS_H
#ifdef HAVE_SYSMACROS_H
#include <sys/sysmacros.h>
#include <sys/sysmacros.h>
#endif
#endif
 
 
#ifdef HAVE_PTYTRAP
#ifdef HAVE_PTYTRAP
#include <sys/ptyio.h>
#include <sys/ptyio.h>
#endif
#endif
 
 
#include <sys/file.h>
#include <sys/file.h>
 
 
#ifdef HAVE_SYS_FCNTL_H
#ifdef HAVE_SYS_FCNTL_H
#  include <sys/fcntl.h>
#  include <sys/fcntl.h>
#else
#else
#  include <fcntl.h>
#  include <fcntl.h>
#endif
#endif
 
 
#if defined(_SEQUENT_)
#if defined(_SEQUENT_)
#  include <sys/strpty.h>
#  include <sys/strpty.h>
#endif
#endif
 
 
#if defined(HAVE_PTMX) && !defined(__CYGWIN32__)
#if defined(HAVE_PTMX) && !defined(__CYGWIN32__)
#  include <sys/stropts.h>
#  include <sys/stropts.h>
#endif
#endif
 
 
#include "exp_win.h"
#include "exp_win.h"
 
 
#include "exp_tty_in.h"
#include "exp_tty_in.h"
#include "exp_rename.h"
#include "exp_rename.h"
#include "exp_pty.h"
#include "exp_pty.h"
 
 
void debuglog();
void debuglog();
 
 
#include <errno.h>
#include <errno.h>
/*extern char *sys_errlist[];*/
/*extern char *sys_errlist[];*/
 
 
#ifndef TRUE
#ifndef TRUE
#define TRUE 1
#define TRUE 1
#define FALSE 0
#define FALSE 0
#endif
#endif
 
 
/* Convex getpty is different than older-style getpty */
/* Convex getpty is different than older-style getpty */
/* Convex getpty is really just a cover function that does the traversal */
/* Convex getpty is really just a cover function that does the traversal */
/* across the domain of pty names.  It makes no attempt to verify that */
/* across the domain of pty names.  It makes no attempt to verify that */
/* they can actually be used.  Indded, the logic in the man page is */
/* they can actually be used.  Indded, the logic in the man page is */
/* wrong because it will allow you to allocate ptys that your own account */
/* wrong because it will allow you to allocate ptys that your own account */
/* already has in use. */
/* already has in use. */
#if defined(HAVE_GETPTY) && defined(CONVEX)
#if defined(HAVE_GETPTY) && defined(CONVEX)
#undef HAVE_GETPTY
#undef HAVE_GETPTY
#define HAVE_CONVEX_GETPTY
#define HAVE_CONVEX_GETPTY
extern char *getpty();
extern char *getpty();
static char *master_name;
static char *master_name;
static char slave_name[] = "/dev/ptyXX";
static char slave_name[] = "/dev/ptyXX";
static char     *tty_bank;              /* ptr to char [p-z] denoting
static char     *tty_bank;              /* ptr to char [p-z] denoting
                                           which bank it is */
                                           which bank it is */
static char     *tty_num;               /* ptr to char [0-f] denoting
static char     *tty_num;               /* ptr to char [0-f] denoting
                                           which number it is */
                                           which number it is */
#endif
#endif
 
 
#if defined(_SEQUENT_) && !defined(HAVE_PTMX)
#if defined(_SEQUENT_) && !defined(HAVE_PTMX)
/* old-style SEQUENT, new-style uses ptmx */
/* old-style SEQUENT, new-style uses ptmx */
static char *master_name, *slave_name;
static char *master_name, *slave_name;
#endif /* _SEQUENT */
#endif /* _SEQUENT */
 
 
/* very old SGIs prefer _getpty over ptc */
/* very old SGIs prefer _getpty over ptc */
#if defined(HAVE__GETPTY) && defined(HAVE_PTC) && !defined(HAVE_GETPTY)
#if defined(HAVE__GETPTY) && defined(HAVE_PTC) && !defined(HAVE_GETPTY)
#undef HAVE_PTC
#undef HAVE_PTC
#endif
#endif
 
 
#if defined(HAVE_PTC)
#if defined(HAVE_PTC)
static char slave_name[] = "/dev/ttyqXXX";
static char slave_name[] = "/dev/ttyqXXX";
/* some machines (e.g., SVR4.0 StarServer) have all of these and */
/* some machines (e.g., SVR4.0 StarServer) have all of these and */
/* HAVE_PTC works best */
/* HAVE_PTC works best */
#undef HAVE_GETPTY
#undef HAVE_GETPTY
#undef HAVE__GETPTY
#undef HAVE__GETPTY
#endif
#endif
 
 
#if defined(HAVE__GETPTY) || defined(HAVE_PTC_PTS) || defined(HAVE_PTMX)
#if defined(HAVE__GETPTY) || defined(HAVE_PTC_PTS) || defined(HAVE_PTMX)
static char *slave_name;
static char *slave_name;
#endif
#endif
 
 
#if defined(HAVE_GETPTY)
#if defined(HAVE_GETPTY)
#include <sys/vty.h>
#include <sys/vty.h>
static char master_name[MAXPTYNAMELEN];
static char master_name[MAXPTYNAMELEN];
static char slave_name[MAXPTYNAMELEN];
static char slave_name[MAXPTYNAMELEN];
#endif
#endif
 
 
#if !defined(HAVE_GETPTY) && !defined(HAVE__GETPTY) && !defined(HAVE_PTC) && !defined(HAVE_PTC_PTS) && !defined(HAVE_PTMX) && !defined(HAVE_CONVEX_GETPTY) && !defined(_SEQUENT_) && !defined(HAVE_SCO_CLIST_PTYS) && !defined(HAVE_OPENPTY)
#if !defined(HAVE_GETPTY) && !defined(HAVE__GETPTY) && !defined(HAVE_PTC) && !defined(HAVE_PTC_PTS) && !defined(HAVE_PTMX) && !defined(HAVE_CONVEX_GETPTY) && !defined(_SEQUENT_) && !defined(HAVE_SCO_CLIST_PTYS) && !defined(HAVE_OPENPTY)
#ifdef HAVE_PTYM
#ifdef HAVE_PTYM
                        /* strange order and missing d is intentional */
                        /* strange order and missing d is intentional */
static char     banks[] = "pqrstuvwxyzabcefghijklo";
static char     banks[] = "pqrstuvwxyzabcefghijklo";
static char     master_name[] = "/dev/ptym/ptyXXXX";
static char     master_name[] = "/dev/ptym/ptyXXXX";
static char     slave_name[] = "/dev/pty/ttyXXXX";
static char     slave_name[] = "/dev/pty/ttyXXXX";
static char     *slave_bank;
static char     *slave_bank;
static char     *slave_num;
static char     *slave_num;
#else
#else
static char     banks[] = "pqrstuvwxyzPQRSTUVWXYZ";
static char     banks[] = "pqrstuvwxyzPQRSTUVWXYZ";
static char     master_name[] = "/dev/ptyXX";
static char     master_name[] = "/dev/ptyXX";
static char     slave_name [] = "/dev/ttyXX";
static char     slave_name [] = "/dev/ttyXX";
#endif /* HAVE_PTYM */
#endif /* HAVE_PTYM */
 
 
static char     *tty_type;              /* ptr to char [pt] denoting
static char     *tty_type;              /* ptr to char [pt] denoting
                                           whether it is a pty or tty */
                                           whether it is a pty or tty */
static char     *tty_bank;              /* ptr to char [p-z] denoting
static char     *tty_bank;              /* ptr to char [p-z] denoting
                                           which bank it is */
                                           which bank it is */
static char     *tty_num;               /* ptr to char [0-f] denoting
static char     *tty_num;               /* ptr to char [0-f] denoting
                                           which number it is */
                                           which number it is */
#endif
#endif
 
 
#if defined(HAVE_SCO_CLIST_PTYS)
#if defined(HAVE_SCO_CLIST_PTYS)
#  define MAXPTYNAMELEN 64
#  define MAXPTYNAMELEN 64
static char master_name[MAXPTYNAMELEN];
static char master_name[MAXPTYNAMELEN];
static char slave_name[MAXPTYNAMELEN];
static char slave_name[MAXPTYNAMELEN];
#endif /* HAVE_SCO_CLIST_PTYS */
#endif /* HAVE_SCO_CLIST_PTYS */
 
 
#ifdef HAVE_OPENPTY
#ifdef HAVE_OPENPTY
static char master_name[64];
static char master_name[64];
static char slave_name[64];
static char slave_name[64];
#endif
#endif
 
 
char *exp_pty_slave_name;
char *exp_pty_slave_name;
char *exp_pty_error;
char *exp_pty_error;
 
 
#if 0
#if 0
static void
static void
pty_stty(s,name)
pty_stty(s,name)
char *s;                /* args to stty */
char *s;                /* args to stty */
char *name;             /* name of pty */
char *name;             /* name of pty */
{
{
#define MAX_ARGLIST 10240
#define MAX_ARGLIST 10240
        char buf[MAX_ARGLIST];  /* overkill is easier */
        char buf[MAX_ARGLIST];  /* overkill is easier */
        RETSIGTYPE (*old)();    /* save old sigalarm handler */
        RETSIGTYPE (*old)();    /* save old sigalarm handler */
        int pid;
        int pid;
 
 
        old = signal(SIGCHLD, SIG_DFL);
        old = signal(SIGCHLD, SIG_DFL);
        switch (pid = fork()) {
        switch (pid = fork()) {
        case 0: /* child */
        case 0: /* child */
                exec_stty("/bin/stty","/bin/stty",s);
                exec_stty("/bin/stty","/bin/stty",s);
                break;
                break;
        case -1: /* fail */
        case -1: /* fail */
        default: /* parent */
        default: /* parent */
                waitpid(pid);
                waitpid(pid);
                break;
                break;
        }
        }
 
 
        signal(SIGCHLD, old);   /* restore signal handler */
        signal(SIGCHLD, old);   /* restore signal handler */
}
}
 
 
exec_stty(s)
exec_stty(s)
char *s;
char *s;
{
{
        char *args[50];
        char *args[50];
        char *cp;
        char *cp;
        int argi = 0;
        int argi = 0;
        int quoting = FALSE;
        int quoting = FALSE;
        int in_token = FALSE;   /* TRUE if we are reading a token */
        int in_token = FALSE;   /* TRUE if we are reading a token */
 
 
        args[0] = cp = s;
        args[0] = cp = s;
        while (*s) {
        while (*s) {
                if (quoting) {
                if (quoting) {
                        if (*s == '\\' && *(s+1) == '"') { /* quoted quote */
                        if (*s == '\\' && *(s+1) == '"') { /* quoted quote */
                                s++;    /* get past " */
                                s++;    /* get past " */
                                *cp++ = *s++;
                                *cp++ = *s++;
                        } else  if (*s == '\"') { /* close quote */
                        } else  if (*s == '\"') { /* close quote */
                                end_token
                                end_token
                                quoting = FALSE;
                                quoting = FALSE;
                        } else *cp++ = *s++; /* suck up anything */
                        } else *cp++ = *s++; /* suck up anything */
                } else if (*s == '\"') { /* open quote */
                } else if (*s == '\"') { /* open quote */
                        in_token = TRUE;
                        in_token = TRUE;
                        quoting = TRUE;
                        quoting = TRUE;
                        s++;
                        s++;
                } else if (isspace(*s)) {
                } else if (isspace(*s)) {
                        end_token
                        end_token
                } else {
                } else {
                        *cp++ = *s++;
                        *cp++ = *s++;
                        in_token = TRUE;
                        in_token = TRUE;
                }
                }
        }
        }
        end_token
        end_token
        args[argi] = (char *) 0; /* terminate argv */
        args[argi] = (char *) 0; /* terminate argv */
        execvp(args[0],args);
        execvp(args[0],args);
}
}
#endif /*0*/
#endif /*0*/
 
 
static void
static void
pty_stty(s,name)
pty_stty(s,name)
char *s;                /* args to stty */
char *s;                /* args to stty */
char *name;             /* name of pty */
char *name;             /* name of pty */
{
{
#define MAX_ARGLIST 10240
#define MAX_ARGLIST 10240
        char buf[MAX_ARGLIST];  /* overkill is easier */
        char buf[MAX_ARGLIST];  /* overkill is easier */
        RETSIGTYPE (*old)();    /* save old sigalarm handler */
        RETSIGTYPE (*old)();    /* save old sigalarm handler */
 
 
#ifdef STTY_READS_STDOUT
#ifdef STTY_READS_STDOUT
        sprintf(buf,"/bin/stty %s > %s",s,name);
        sprintf(buf,"/bin/stty %s > %s",s,name);
#else
#else
#ifdef __CYGWIN32__
#ifdef __CYGWIN32__
        sprintf(buf,"stty %s < %s",s,name);
        sprintf(buf,"stty %s < %s",s,name);
#else
#else
        sprintf(buf,"/bin/stty %s < %s",s,name);
        sprintf(buf,"/bin/stty %s < %s",s,name);
#endif
#endif
#endif
#endif
        old = signal(SIGCHLD, SIG_DFL);
        old = signal(SIGCHLD, SIG_DFL);
        system(buf);
        system(buf);
        signal(SIGCHLD, old);   /* restore signal handler */
        signal(SIGCHLD, old);   /* restore signal handler */
}
}
 
 
int exp_dev_tty;        /* file descriptor to /dev/tty or -1 if none */
int exp_dev_tty;        /* file descriptor to /dev/tty or -1 if none */
static int knew_dev_tty;/* true if we had our hands on /dev/tty at any time */
static int knew_dev_tty;/* true if we had our hands on /dev/tty at any time */
 
 
exp_tty exp_tty_original;
exp_tty exp_tty_original;
 
 
#define GET_TTYTYPE     0
#define GET_TTYTYPE     0
#define SET_TTYTYPE     1
#define SET_TTYTYPE     1
static void
static void
ttytype(request,fd,ttycopy,ttyinit,s)
ttytype(request,fd,ttycopy,ttyinit,s)
int request;
int request;
int fd;
int fd;
                /* following are used only if request == SET_TTYTYPE */
                /* following are used only if request == SET_TTYTYPE */
int ttycopy;    /* true/false, copy from /dev/tty */
int ttycopy;    /* true/false, copy from /dev/tty */
int ttyinit;    /* if true, initialize to sane state */
int ttyinit;    /* if true, initialize to sane state */
char *s;        /* stty args */
char *s;        /* stty args */
{
{
        if (request == GET_TTYTYPE) {
        if (request == GET_TTYTYPE) {
#ifdef HAVE_TCSETATTR
#ifdef HAVE_TCSETATTR
                if (-1 == tcgetattr(fd, &exp_tty_original)) {
                if (-1 == tcgetattr(fd, &exp_tty_original)) {
#else
#else
                if (-1 == ioctl(fd, TCGETS, (char *)&exp_tty_original)) {
                if (-1 == ioctl(fd, TCGETS, (char *)&exp_tty_original)) {
#endif
#endif
                        knew_dev_tty = FALSE;
                        knew_dev_tty = FALSE;
                        exp_dev_tty = -1;
                        exp_dev_tty = -1;
                }
                }
                exp_window_size_get(fd);
                exp_window_size_get(fd);
        } else {        /* type == SET_TTYTYPE */
        } else {        /* type == SET_TTYTYPE */
                if (ttycopy && knew_dev_tty) {
                if (ttycopy && knew_dev_tty) {
#ifdef HAVE_TCSETATTR
#ifdef HAVE_TCSETATTR
                        (void) tcsetattr(fd, TCSADRAIN, &exp_tty_current);
                        (void) tcsetattr(fd, TCSADRAIN, &exp_tty_current);
#else
#else
                        (void) ioctl(fd, TCSETS, (char *)&exp_tty_current);
                        (void) ioctl(fd, TCSETS, (char *)&exp_tty_current);
#endif
#endif
 
 
                        exp_window_size_set(fd);
                        exp_window_size_set(fd);
                }
                }
 
 
#ifdef __CENTERLINE__
#ifdef __CENTERLINE__
#undef DFLT_STTY
#undef DFLT_STTY
#define DFLT_STTY "sane"
#define DFLT_STTY "sane"
#endif
#endif
 
 
/* Apollo Domain doesn't need this */
/* Apollo Domain doesn't need this */
#ifdef DFLT_STTY
#ifdef DFLT_STTY
                if (ttyinit) {
                if (ttyinit) {
                        /* overlay parms originally supplied by Makefile */
                        /* overlay parms originally supplied by Makefile */
/* As long as BSD stty insists on stdout == stderr, we can no longer write */
/* As long as BSD stty insists on stdout == stderr, we can no longer write */
/* diagnostics to parent stderr, since stderr has is now child's */
/* diagnostics to parent stderr, since stderr has is now child's */
/* Maybe someday they will fix stty? */
/* Maybe someday they will fix stty? */
/*                      debuglog("getptyslave: (default) stty %s\n",DFLT_STTY);*/
/*                      debuglog("getptyslave: (default) stty %s\n",DFLT_STTY);*/
                        pty_stty(DFLT_STTY,slave_name);
                        pty_stty(DFLT_STTY,slave_name);
                }
                }
#endif
#endif
 
 
                /* lastly, give user chance to override any terminal parms */
                /* lastly, give user chance to override any terminal parms */
                if (s) {
                if (s) {
                        /* give user a chance to override any terminal parms */
                        /* give user a chance to override any terminal parms */
/*                      debuglog("getptyslave: (user-requested) stty %s\n",s);*/
/*                      debuglog("getptyslave: (user-requested) stty %s\n",s);*/
                        pty_stty(s,slave_name);
                        pty_stty(s,slave_name);
                }
                }
        }
        }
}
}
 
 
void
void
exp_init_pty()
exp_init_pty()
{
{
#if !defined(HAVE_GETPTY) && !defined(HAVE__GETPTY) && !defined(HAVE_PTC) && !defined(HAVE_PTC_PTS) && !defined(HAVE_PTMX) && !defined(HAVE_CONVEX_GETPTY) && !defined(_SEQUENT_) && !defined(HAVE_SCO_CLIST_PTYS) && !defined(HAVE_OPENPTY)
#if !defined(HAVE_GETPTY) && !defined(HAVE__GETPTY) && !defined(HAVE_PTC) && !defined(HAVE_PTC_PTS) && !defined(HAVE_PTMX) && !defined(HAVE_CONVEX_GETPTY) && !defined(_SEQUENT_) && !defined(HAVE_SCO_CLIST_PTYS) && !defined(HAVE_OPENPTY)
#ifdef HAVE_PTYM
#ifdef HAVE_PTYM
        static char dummy;
        static char dummy;
        tty_bank =  &master_name[strlen("/dev/ptym/pty")];
        tty_bank =  &master_name[strlen("/dev/ptym/pty")];
        tty_num  =  &master_name[strlen("/dev/ptym/ptyX")];
        tty_num  =  &master_name[strlen("/dev/ptym/ptyX")];
        slave_bank = &slave_name[strlen("/dev/pty/tty")];
        slave_bank = &slave_name[strlen("/dev/pty/tty")];
        slave_num  = &slave_name[strlen("/dev/pty/ttyX")];
        slave_num  = &slave_name[strlen("/dev/pty/ttyX")];
#else
#else
        tty_bank =  &master_name[strlen("/dev/pty")];
        tty_bank =  &master_name[strlen("/dev/pty")];
        tty_num  =  &master_name[strlen("/dev/ptyp")];
        tty_num  =  &master_name[strlen("/dev/ptyp")];
        tty_type =   &slave_name[strlen("/dev/")];
        tty_type =   &slave_name[strlen("/dev/")];
#endif
#endif
 
 
#endif /* HAVE_PTYM */
#endif /* HAVE_PTYM */
 
 
 
 
        exp_dev_tty = open("/dev/tty",O_RDWR);
        exp_dev_tty = open("/dev/tty",O_RDWR);
        knew_dev_tty = (exp_dev_tty != -1);
        knew_dev_tty = (exp_dev_tty != -1);
        if (knew_dev_tty) ttytype(GET_TTYTYPE,exp_dev_tty,0,0,(char *)0);
        if (knew_dev_tty) ttytype(GET_TTYTYPE,exp_dev_tty,0,0,(char *)0);
}
}
 
 
#ifndef R_OK
#ifndef R_OK
/* 3b2 doesn't define these according to jthomas@nmsu.edu. */
/* 3b2 doesn't define these according to jthomas@nmsu.edu. */
#define R_OK 04
#define R_OK 04
#define W_OK 02
#define W_OK 02
#endif
#endif
 
 
int
int
getptymaster()
getptymaster()
{
{
        char *hex, *bank;
        char *hex, *bank;
        struct stat stat_buf;
        struct stat stat_buf;
        int master = -1;
        int master = -1;
        int slave = -1;
        int slave = -1;
        int num;
        int num;
 
 
        exp_pty_error = 0;
        exp_pty_error = 0;
 
 
#define TEST_PTY 1
#define TEST_PTY 1
 
 
#if defined(HAVE_PTMX) || defined(HAVE_PTMX_BSD)
#if defined(HAVE_PTMX) || defined(HAVE_PTMX_BSD)
#undef TEST_PTY
#undef TEST_PTY
#if defined(HAVE_PTMX_BSD)
#if defined(HAVE_PTMX_BSD)
        if ((master = open("/dev/ptmx_bsd", O_RDWR)) == -1) return(-1);
        if ((master = open("/dev/ptmx_bsd", O_RDWR)) == -1) return(-1);
#else
#else
        if ((master = open("/dev/ptmx", O_RDWR)) == -1) return(-1);
        if ((master = open("/dev/ptmx", O_RDWR)) == -1) return(-1);
#endif
#endif
        if ((slave_name = (char *)ptsname(master)) == NULL || unlockpt(master)) {
        if ((slave_name = (char *)ptsname(master)) == NULL || unlockpt(master)) {
                close(master);
                close(master);
                return(-1);
                return(-1);
        } else if (grantpt(master)) {
        } else if (grantpt(master)) {
                static char buf[500];
                static char buf[500];
                exp_pty_error = buf;
                exp_pty_error = buf;
                sprintf(exp_pty_error,"grantpt(%d) failed - likely reason is that your system administrator (in a rage of blind passion to rid the system of security holes) removed setuid from the utility used internally by grantpt to change pty permissions.  Tell your system admin to reestablish setuid on the utility.  Get the utility name by running Expect under truss or trace.");
                sprintf(exp_pty_error,"grantpt(%d) failed - likely reason is that your system administrator (in a rage of blind passion to rid the system of security holes) removed setuid from the utility used internally by grantpt to change pty permissions.  Tell your system admin to reestablish setuid on the utility.  Get the utility name by running Expect under truss or trace.");
                close(master);
                close(master);
                return(-1);
                return(-1);
        }
        }
#ifdef TIOCFLUSH
#ifdef TIOCFLUSH
        (void) ioctl(master,TIOCFLUSH,(char *)0);
        (void) ioctl(master,TIOCFLUSH,(char *)0);
#endif /* TIOCFLUSH */
#endif /* TIOCFLUSH */
 
 
        exp_pty_slave_name = slave_name;
        exp_pty_slave_name = slave_name;
        return(master);
        return(master);
#endif
#endif
 
 
#if defined(HAVE__GETPTY)               /* SGI needs it this way */
#if defined(HAVE__GETPTY)               /* SGI needs it this way */
#undef TEST_PTY
#undef TEST_PTY
        slave_name = _getpty(&master, O_RDWR, 0600, 0);
        slave_name = _getpty(&master, O_RDWR, 0600, 0);
        if (slave_name == NULL)
        if (slave_name == NULL)
                return (-1);
                return (-1);
        exp_pty_slave_name = slave_name;
        exp_pty_slave_name = slave_name;
        return(master);
        return(master);
#endif
#endif
 
 
#if defined(HAVE_PTC) && !defined(HAVE__GETPTY) /* old SGI, version 3 */
#if defined(HAVE_PTC) && !defined(HAVE__GETPTY) /* old SGI, version 3 */
#undef TEST_PTY
#undef TEST_PTY
        master = open("/dev/ptc", O_RDWR);
        master = open("/dev/ptc", O_RDWR);
        if (master >= 0) {
        if (master >= 0) {
                int ptynum;
                int ptynum;
 
 
                if (fstat(master, &stat_buf) < 0) {
                if (fstat(master, &stat_buf) < 0) {
                        close(master);
                        close(master);
                        return(-1);
                        return(-1);
                }
                }
                ptynum = minor(stat_buf.st_rdev);
                ptynum = minor(stat_buf.st_rdev);
                sprintf(slave_name,"/dev/ttyq%d",ptynum);
                sprintf(slave_name,"/dev/ttyq%d",ptynum);
        }
        }
        exp_pty_slave_name = slave_name;
        exp_pty_slave_name = slave_name;
        return(master);
        return(master);
#endif
#endif
 
 
#if defined(HAVE_GETPTY) && !defined(HAVE__GETPTY)
#if defined(HAVE_GETPTY) && !defined(HAVE__GETPTY)
#undef TEST_PTY
#undef TEST_PTY
        master = getpty(master_name, slave_name, O_RDWR);
        master = getpty(master_name, slave_name, O_RDWR);
        /* is it really necessary to verify slave side is usable? */
        /* is it really necessary to verify slave side is usable? */
        exp_pty_slave_name = slave_name;
        exp_pty_slave_name = slave_name;
        return master;
        return master;
#endif
#endif
 
 
#if defined(HAVE_PTC_PTS)
#if defined(HAVE_PTC_PTS)
#undef TEST_PTY
#undef TEST_PTY
        master = open("/dev/ptc",O_RDWR);
        master = open("/dev/ptc",O_RDWR);
        if (master >= 0) {
        if (master >= 0) {
                /* never fails */
                /* never fails */
                slave_name = ttyname(master);
                slave_name = ttyname(master);
        }
        }
        exp_pty_slave_name = slave_name;
        exp_pty_slave_name = slave_name;
        return(master);
        return(master);
#endif
#endif
 
 
#if defined(_SEQUENT_) && !defined(HAVE_PTMX)
#if defined(_SEQUENT_) && !defined(HAVE_PTMX)
#undef TEST_PTY
#undef TEST_PTY
        /* old-style SEQUENT, new-style uses ptmx */
        /* old-style SEQUENT, new-style uses ptmx */
        master = getpseudotty(&slave_name, &master_name);
        master = getpseudotty(&slave_name, &master_name);
        exp_pty_slave_name = slave_name;
        exp_pty_slave_name = slave_name;
        return(master);
        return(master);
#endif /* _SEQUENT_ */
#endif /* _SEQUENT_ */
 
 
#if defined(HAVE_OPENPTY)
#if defined(HAVE_OPENPTY)
#undef TEST_PTY
#undef TEST_PTY
        if (openpty(&master, &slave, master_name, 0, 0) != 0) {
        if (openpty(&master, &slave, master_name, 0, 0) != 0) {
                close(master);
                close(master);
                close(slave);
                close(slave);
                return -1;
                return -1;
        }
        }
        strcpy(slave_name, ttyname(slave));
        strcpy(slave_name, ttyname(slave));
        exp_pty_slave_name = slave_name;
        exp_pty_slave_name = slave_name;
        close(slave);
        close(slave);
        return master;
        return master;
#endif /* HAVE_OPENPTY */
#endif /* HAVE_OPENPTY */
 
 
#if defined(TEST_PTY)
#if defined(TEST_PTY)
        /*
        /*
         * all pty allocation mechanisms after this require testing
         * all pty allocation mechanisms after this require testing
         */
         */
        if (exp_pty_test_start() == -1) return -1;
        if (exp_pty_test_start() == -1) return -1;
 
 
#if !defined(HAVE_CONVEX_GETPTY) && !defined(HAVE_PTYM) && !defined(HAVE_SCO_CLIST_PTYS)
#if !defined(HAVE_CONVEX_GETPTY) && !defined(HAVE_PTYM) && !defined(HAVE_SCO_CLIST_PTYS)
        for (bank = banks;*bank;bank++) {
        for (bank = banks;*bank;bank++) {
                *tty_bank = *bank;
                *tty_bank = *bank;
                *tty_num = '0';
                *tty_num = '0';
                if (stat(master_name, &stat_buf) < 0) break;
                if (stat(master_name, &stat_buf) < 0) break;
                for (hex = "0123456789abcdef";*hex;hex++) {
                for (hex = "0123456789abcdef";*hex;hex++) {
                        *tty_num = *hex;
                        *tty_num = *hex;
                        strcpy(slave_name,master_name);
                        strcpy(slave_name,master_name);
                        *tty_type = 't';
                        *tty_type = 't';
                        master = exp_pty_test(master_name,slave_name,*tty_bank,tty_num);
                        master = exp_pty_test(master_name,slave_name,*tty_bank,tty_num);
                        if (master >= 0) goto done;
                        if (master >= 0) goto done;
                }
                }
        }
        }
#endif
#endif
 
 
#ifdef HAVE_SCO_CLIST_PTYS
#ifdef HAVE_SCO_CLIST_PTYS
        for (num = 0; ; num++) {
        for (num = 0; ; num++) {
            char num_str [16];
            char num_str [16];
 
 
            sprintf (num_str, "%d", num);
            sprintf (num_str, "%d", num);
            sprintf (master_name, "%s%s", "/dev/ptyp", num_str);
            sprintf (master_name, "%s%s", "/dev/ptyp", num_str);
            if (stat (master_name, &stat_buf) < 0)
            if (stat (master_name, &stat_buf) < 0)
                break;
                break;
            sprintf (slave_name, "%s%s", "/dev/ttyp", num_str);
            sprintf (slave_name, "%s%s", "/dev/ttyp", num_str);
 
 
            master = exp_pty_test (master_name, slave_name, 0, num_str);
            master = exp_pty_test (master_name, slave_name, 0, num_str);
            if (master >= 0)
            if (master >= 0)
                goto done;
                goto done;
        }
        }
#endif
#endif
 
 
#ifdef HAVE_PTYM
#ifdef HAVE_PTYM
        /* systems with PTYM follow this idea:
        /* systems with PTYM follow this idea:
 
 
           /dev/ptym/pty[a-ce-z][0-9a-f]                master pseudo terminals
           /dev/ptym/pty[a-ce-z][0-9a-f]                master pseudo terminals
           /dev/pty/tty[a-ce-z][0-9a-f]                 slave pseudo terminals
           /dev/pty/tty[a-ce-z][0-9a-f]                 slave pseudo terminals
           /dev/ptym/pty[a-ce-z][0-9][0-9]              master pseudo terminals
           /dev/ptym/pty[a-ce-z][0-9][0-9]              master pseudo terminals
           /dev/pty/tty[a-ce-z][0-9][0-9]               slave pseudo terminals
           /dev/pty/tty[a-ce-z][0-9][0-9]               slave pseudo terminals
 
 
           SPPUX (Convex's HPUX compatible) follows the PTYM convention but
           SPPUX (Convex's HPUX compatible) follows the PTYM convention but
           extends it:
           extends it:
 
 
           /dev/ptym/pty[a-ce-z][0-9][0-9][0-9]         master pseudo terminals
           /dev/ptym/pty[a-ce-z][0-9][0-9][0-9]         master pseudo terminals
           /dev/pty/tty[a-ce-z][0-9][0-9][0-9]          slave pseudo terminals
           /dev/pty/tty[a-ce-z][0-9][0-9][0-9]          slave pseudo terminals
 
 
           The code does not distinguish between HPUX and SPPUX because there
           The code does not distinguish between HPUX and SPPUX because there
           is no reason to.  HPUX will merely fail the extended SPPUX tests.
           is no reason to.  HPUX will merely fail the extended SPPUX tests.
           In fact, most SPPUX systems will fail simply because few systems
           In fact, most SPPUX systems will fail simply because few systems
           will actually have the extended ptys.  However, the tests are
           will actually have the extended ptys.  However, the tests are
           fast so it is no big deal.
           fast so it is no big deal.
         */
         */
 
 
        /*
        /*
         * pty[a-ce-z][0-9a-f]
         * pty[a-ce-z][0-9a-f]
         */
         */
 
 
        for (bank = banks;*bank;bank++) {
        for (bank = banks;*bank;bank++) {
                *tty_bank = *bank;
                *tty_bank = *bank;
                sprintf(tty_num,"0");
                sprintf(tty_num,"0");
                if (stat(master_name, &stat_buf) < 0) break;
                if (stat(master_name, &stat_buf) < 0) break;
                *(slave_num+1) = '\0';
                *(slave_num+1) = '\0';
                for (hex = "0123456789abcdef";*hex;hex++) {
                for (hex = "0123456789abcdef";*hex;hex++) {
                        *tty_num = *hex;
                        *tty_num = *hex;
                        *slave_bank = *tty_bank;
                        *slave_bank = *tty_bank;
                        *slave_num = *tty_num;
                        *slave_num = *tty_num;
                        master = exp_pty_test(master_name,slave_name,*tty_bank,tty_num);
                        master = exp_pty_test(master_name,slave_name,*tty_bank,tty_num);
                        if (master >= 0) goto done;
                        if (master >= 0) goto done;
                }
                }
        }
        }
 
 
        /*
        /*
         * tty[p-za-ce-o][0-9][0-9]
         * tty[p-za-ce-o][0-9][0-9]
         */
         */
 
 
        for (bank = banks;*bank;bank++) {
        for (bank = banks;*bank;bank++) {
                *tty_bank = *bank;
                *tty_bank = *bank;
                sprintf(tty_num,"00");
                sprintf(tty_num,"00");
                if (stat(master_name, &stat_buf) < 0) break;
                if (stat(master_name, &stat_buf) < 0) break;
                for (num = 0; num<100; num++) {
                for (num = 0; num<100; num++) {
                        *slave_bank = *tty_bank;
                        *slave_bank = *tty_bank;
                        sprintf(tty_num,"%02d",num);
                        sprintf(tty_num,"%02d",num);
                        strcpy(slave_num,tty_num);
                        strcpy(slave_num,tty_num);
                        master = exp_pty_test(master_name,slave_name,tty_bank,tty_num);
                        master = exp_pty_test(master_name,slave_name,tty_bank,tty_num);
                        if (master >= 0) goto done;
                        if (master >= 0) goto done;
                }
                }
        }
        }
 
 
        /*
        /*
         * tty[p-za-ce-o][0-9][0-9][0-9]
         * tty[p-za-ce-o][0-9][0-9][0-9]
         */
         */
        for (bank = banks;*bank;bank++) {
        for (bank = banks;*bank;bank++) {
                *tty_bank = *bank;
                *tty_bank = *bank;
                sprintf(tty_num,"000");
                sprintf(tty_num,"000");
                if (stat(master_name, &stat_buf) < 0) break;
                if (stat(master_name, &stat_buf) < 0) break;
                for (num = 0; num<1000; num++) {
                for (num = 0; num<1000; num++) {
                        *slave_bank = *tty_bank;
                        *slave_bank = *tty_bank;
                        sprintf(tty_num,"%03d",num);
                        sprintf(tty_num,"%03d",num);
                        strcpy(slave_num,tty_num);
                        strcpy(slave_num,tty_num);
                        master = exp_pty_test(master_name,slave_name,tty_bank,tty_num);
                        master = exp_pty_test(master_name,slave_name,tty_bank,tty_num);
                        if (master >= 0) goto done;
                        if (master >= 0) goto done;
                }
                }
        }
        }
 
 
#endif /* HAVE_PTYM */
#endif /* HAVE_PTYM */
 
 
#if defined(HAVE_CONVEX_GETPTY)
#if defined(HAVE_CONVEX_GETPTY)
        for (;;) {
        for (;;) {
                if ((master_name = getpty()) == NULL) return -1;
                if ((master_name = getpty()) == NULL) return -1;
 
 
                strcpy(slave_name,master_name);
                strcpy(slave_name,master_name);
                slave_name[5] = 't';/* /dev/ptyXY ==> /dev/ttyXY */
                slave_name[5] = 't';/* /dev/ptyXY ==> /dev/ttyXY */
 
 
                tty_bank = &slave_name[8];
                tty_bank = &slave_name[8];
                tty_num = &slave_name[9];
                tty_num = &slave_name[9];
                master = exp_pty_test(master_name,slave_name,*tty_bank,tty_num);
                master = exp_pty_test(master_name,slave_name,*tty_bank,tty_num);
                if (master >= 0) goto done;
                if (master >= 0) goto done;
        }
        }
#endif
#endif
 
 
 done:
 done:
        exp_pty_test_end();
        exp_pty_test_end();
        exp_pty_slave_name = slave_name;
        exp_pty_slave_name = slave_name;
        return(master);
        return(master);
 
 
#endif /* defined(TEST_PTY) */
#endif /* defined(TEST_PTY) */
}
}
 
 
/* if slave is opened in a child, slave_control(1) must be executed after */
/* if slave is opened in a child, slave_control(1) must be executed after */
/*   master is opened (when child is opened is irrelevent) */
/*   master is opened (when child is opened is irrelevent) */
/* if slave is opened in same proc as master, slave_control(1) must executed */
/* if slave is opened in same proc as master, slave_control(1) must executed */
/*   after slave is opened */
/*   after slave is opened */
/*ARGSUSED*/
/*ARGSUSED*/
void
void
exp_slave_control(master,control)
exp_slave_control(master,control)
int master;
int master;
int control;    /* if 1, enable pty trapping of close/open/ioctl */
int control;    /* if 1, enable pty trapping of close/open/ioctl */
{
{
#ifdef HAVE_PTYTRAP
#ifdef HAVE_PTYTRAP
        ioctl(master, TIOCTRAP, &control);
        ioctl(master, TIOCTRAP, &control);
#endif /* HAVE_PTYTRAP */
#endif /* HAVE_PTYTRAP */
}
}
 
 
int
int
getptyslave(ttycopy,ttyinit,stty_args)
getptyslave(ttycopy,ttyinit,stty_args)
int ttycopy;
int ttycopy;
int ttyinit;
int ttyinit;
char *stty_args;
char *stty_args;
{
{
        int slave, slave2;
        int slave, slave2;
        char buf[10240];
        char buf[10240];
 
 
        if (0 > (slave = open(slave_name, O_RDWR))) return(-1);
        if (0 > (slave = open(slave_name, O_RDWR))) return(-1);
 
 
#if defined(HAVE_PTMX_BSD)
#if defined(HAVE_PTMX_BSD)
        if (ioctl (slave, I_LOOK, buf) != 0)
        if (ioctl (slave, I_LOOK, buf) != 0)
                if (ioctl (slave, I_PUSH, "ldterm")) {
                if (ioctl (slave, I_PUSH, "ldterm")) {
                        debuglog("ioctl(%s,I_PUSH,\"ldterm\") = %s\n",Tcl_ErrnoMsg(errno));
                        debuglog("ioctl(%s,I_PUSH,\"ldterm\") = %s\n",Tcl_ErrnoMsg(errno));
        }
        }
#else
#else
#if defined(HAVE_PTMX) && ! defined(__CYGWIN32__)
#if defined(HAVE_PTMX) && ! defined(__CYGWIN32__)
        if (ioctl(slave, I_PUSH, "ptem")) {
        if (ioctl(slave, I_PUSH, "ptem")) {
                debuglog("ioctl(%s,I_PUSH,\"ptem\") = %s\n",Tcl_ErrnoMsg(errno));
                debuglog("ioctl(%s,I_PUSH,\"ptem\") = %s\n",Tcl_ErrnoMsg(errno));
        }
        }
        if (ioctl(slave, I_PUSH, "ldterm")) {
        if (ioctl(slave, I_PUSH, "ldterm")) {
                debuglog("ioctl(%s,I_PUSH,\"ldterm\") = %s\n",Tcl_ErrnoMsg(errno));
                debuglog("ioctl(%s,I_PUSH,\"ldterm\") = %s\n",Tcl_ErrnoMsg(errno));
        }
        }
        if (ioctl(slave, I_PUSH, "ttcompat")) {
        if (ioctl(slave, I_PUSH, "ttcompat")) {
                debuglog("ioctl(%s,I_PUSH,\"ttcompat\") = %s\n",Tcl_ErrnoMsg(errno));
                debuglog("ioctl(%s,I_PUSH,\"ttcompat\") = %s\n",Tcl_ErrnoMsg(errno));
        }
        }
#endif
#endif
#endif
#endif
 
 
        if (0 == slave) {
        if (0 == slave) {
                /* if opened in a new process, slave will be 0 (and */
                /* if opened in a new process, slave will be 0 (and */
                /* ultimately, 1 and 2 as well) */
                /* ultimately, 1 and 2 as well) */
 
 
                /* duplicate 0 onto 1 and 2 to prepare for stty */
                /* duplicate 0 onto 1 and 2 to prepare for stty */
                fcntl(0,F_DUPFD,1);
                fcntl(0,F_DUPFD,1);
                fcntl(0,F_DUPFD,2);
                fcntl(0,F_DUPFD,2);
        }
        }
 
 
        ttytype(SET_TTYTYPE,slave,ttycopy,ttyinit,stty_args);
        ttytype(SET_TTYTYPE,slave,ttycopy,ttyinit,stty_args);
 
 
#if 0
#if 0
#ifdef HAVE_PTYTRAP
#ifdef HAVE_PTYTRAP
        /* do another open, to tell master that slave is done fiddling */
        /* do another open, to tell master that slave is done fiddling */
        /* with pty and master does not have to wait to do further acks */
        /* with pty and master does not have to wait to do further acks */
        if (0 > (slave2 = open(slave_name, O_RDWR))) return(-1);
        if (0 > (slave2 = open(slave_name, O_RDWR))) return(-1);
        close(slave2);
        close(slave2);
#endif /* HAVE_PTYTRAP */
#endif /* HAVE_PTYTRAP */
#endif
#endif
 
 
        (void) exp_pty_unlock();
        (void) exp_pty_unlock();
        return(slave);
        return(slave);
}
}
 
 
#ifdef HAVE_PTYTRAP
#ifdef HAVE_PTYTRAP
#include <sys/ptyio.h>
#include <sys/ptyio.h>
#include <sys/time.h>
#include <sys/time.h>
 
 
/* This function attempts to deal with HP's pty interface.  This
/* This function attempts to deal with HP's pty interface.  This
function simply returns an indication of what was trapped (or -1 for
function simply returns an indication of what was trapped (or -1 for
failure), the parent deals with the details.
failure), the parent deals with the details.
 
 
Originally, I tried to just trap open's but that is not enough.  When
Originally, I tried to just trap open's but that is not enough.  When
the pty is initialized, ioctl's are generated and if not trapped will
the pty is initialized, ioctl's are generated and if not trapped will
hang the child if no further trapping is done.  (This could occur if
hang the child if no further trapping is done.  (This could occur if
parent spawns a process and then immediatley does a close.)  So
parent spawns a process and then immediatley does a close.)  So
instead, the parent must trap the ioctl's.  It probably suffices to
instead, the parent must trap the ioctl's.  It probably suffices to
trap the write ioctl's (and tiocsctty which some hp's need) -
trap the write ioctl's (and tiocsctty which some hp's need) -
conceivably, stty could be smart enough not to do write's if the tty
conceivably, stty could be smart enough not to do write's if the tty
settings are already correct.  In that case, we'll have to rethink
settings are already correct.  In that case, we'll have to rethink
this.
this.
 
 
Suggestions from HP engineers encouraged.  I cannot imagine how this
Suggestions from HP engineers encouraged.  I cannot imagine how this
interface was intended to be used!
interface was intended to be used!
 
 
*/
*/
 
 
int
int
exp_wait_for_slave_open(fd)
exp_wait_for_slave_open(fd)
int fd;
int fd;
{
{
        fd_set excep;
        fd_set excep;
        struct timeval t;
        struct timeval t;
        struct request_info ioctl_info;
        struct request_info ioctl_info;
        int rc;
        int rc;
        int found = 0;
        int found = 0;
 
 
        int maxfds = sysconf(_SC_OPEN_MAX);
        int maxfds = sysconf(_SC_OPEN_MAX);
 
 
        t.tv_sec = 30;  /* 30 seconds */
        t.tv_sec = 30;  /* 30 seconds */
        t.tv_usec = 0;
        t.tv_usec = 0;
 
 
        FD_ZERO(&excep);
        FD_ZERO(&excep);
        FD_SET(fd,&excep);
        FD_SET(fd,&excep);
 
 
        rc = select(maxfds,
        rc = select(maxfds,
                (SELECT_MASK_TYPE *)0,
                (SELECT_MASK_TYPE *)0,
                (SELECT_MASK_TYPE *)0,
                (SELECT_MASK_TYPE *)0,
                (SELECT_MASK_TYPE *)&excep,
                (SELECT_MASK_TYPE *)&excep,
                &t);
                &t);
        if (rc != 1) {
        if (rc != 1) {
                debuglog("spawned process never started, errno = %d\n",errno);
                debuglog("spawned process never started, errno = %d\n",errno);
                return(-1);
                return(-1);
        }
        }
        if (ioctl(fd,TIOCREQCHECK,&ioctl_info) < 0) {
        if (ioctl(fd,TIOCREQCHECK,&ioctl_info) < 0) {
                debuglog("ioctl(TIOCREQCHECK) failed, errno = %d\n",errno);
                debuglog("ioctl(TIOCREQCHECK) failed, errno = %d\n",errno);
                return(-1);
                return(-1);
        }
        }
 
 
        found = ioctl_info.request;
        found = ioctl_info.request;
 
 
        debuglog("trapped pty op = %x",found);
        debuglog("trapped pty op = %x",found);
        if (found == TIOCOPEN) {
        if (found == TIOCOPEN) {
                debuglog(" TIOCOPEN");
                debuglog(" TIOCOPEN");
        } else if (found == TIOCCLOSE) {
        } else if (found == TIOCCLOSE) {
                debuglog(" TIOCCLOSE");
                debuglog(" TIOCCLOSE");
        }
        }
 
 
#ifdef TIOCSCTTY
#ifdef TIOCSCTTY
        if (found == TIOCSCTTY) {
        if (found == TIOCSCTTY) {
                debuglog(" TIOCSCTTY");
                debuglog(" TIOCSCTTY");
        }
        }
#endif
#endif
 
 
        if (found & IOC_IN) {
        if (found & IOC_IN) {
                debuglog(" IOC_IN (set)");
                debuglog(" IOC_IN (set)");
        } else if (found & IOC_OUT) {
        } else if (found & IOC_OUT) {
                debuglog(" IOC_OUT (get)");
                debuglog(" IOC_OUT (get)");
        }
        }
 
 
        debuglog("\n");
        debuglog("\n");
 
 
        if (ioctl(fd, TIOCREQSET, &ioctl_info) < 0) {
        if (ioctl(fd, TIOCREQSET, &ioctl_info) < 0) {
                debuglog("ioctl(TIOCREQSET) failed, errno = %d\n",errno);
                debuglog("ioctl(TIOCREQSET) failed, errno = %d\n",errno);
                return(-1);
                return(-1);
        }
        }
        return(found);
        return(found);
}
}
#endif
#endif
 
 
void
void
exp_pty_exit()
exp_pty_exit()
{
{
        /* a stub so we can do weird things on the cray */
        /* a stub so we can do weird things on the cray */
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.