# HG changeset patch # User Claus Gittinger # Date 897395216 -7200 # Node ID 126b23939933ea5ef3c72815f4838a3df449cdf1 # Parent 59e6bc687f1ed09a9c84ccdefe890b7d0edcdbf1 added makePTYPair (IRIX only - for now) diff -r 59e6bc687f1e -r 126b23939933 UnixOS.st --- a/UnixOS.st Tue Jun 09 14:06:26 1998 +0200 +++ b/UnixOS.st Tue Jun 09 14:26:56 1998 +0200 @@ -3033,10 +3033,14 @@ ** first: dup filedescriptors */ for (i = 0; i < nfd; i++) { - if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) && - __intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i - ) { - dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i); + OBJ fd; + int rslt; + + fd = __ArrayInstPtr(fdArray)->a_element[i]; + if (__isSmallInteger(fd) && (__intVal(fd) != i)) { + do { + rslt = dup2(__intVal(fd), i); + } while ((rslt < 0) && (errno == EINTR)); } } /* @@ -3051,8 +3055,11 @@ ** third: close filedescriptors */ for (i = 0; i < nclose; i++) { - if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) { - close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i])); + OBJ fd; + + fd = __ArrayInstPtr(closeFdArray)->a_element[i]; + if (__isSmallInteger(fd)) { + close(__intVal(fd)); } } if (newPgrp == true) { @@ -5564,6 +5571,52 @@ !UnixOperatingSystem class methodsFor:'ipc support - UNIX'! +makePTYPair + "make a pipe, return array with two filedescriptors on success, + nil on failure. + This is a lowLevel entry, not for public use. + See ExternalStream>>makePipe for a more user-friendly, public interface." + + |fdS fdM| + +%{ +#ifdef IRIX +/* #include /* */ +/* #include /* */ + + int _fdM, _fdS; + char *line; + + /* + * Find a pseudo tty to use and open both sides. + * filedes[0] receives the master file descriptor while filedes[1] + * receives the slave. The master is opened with O_NDELAY as commonly + * needed in daemons such as rlogind and telnetd. + */ + + line = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0); + if ((line != 0) && (_fdM >= 0)) { + printf("opening slave side %s\n", line); + _fdS = open(line, O_RDWR); + if (_fdS < 0) { + (void)close(_fdM); + _fdS = _fdM = -1; + } + } else { + _fdM -1; + } + if ((_fdM >= 0) && (_fdS >= 0)) { + fdM = __MKSMALLINT(_fdM); + fdS = __MKSMALLINT(_fdS); + } +#endif +%}. + fdM notNil ifTrue:[ + ^ Array with:fdM with:fdS. + ]. + ^ nil +! + makePipe "make a pipe, return array with two filedescriptors on success, nil on failure. @@ -8100,6 +8153,6 @@ !UnixOperatingSystem class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Attic/UnixOS.st,v 1.5 1998-06-05 17:10:27 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Attic/UnixOS.st,v 1.6 1998-06-09 12:26:56 cg Exp $' ! ! UnixOperatingSystem initialize! diff -r 59e6bc687f1e -r 126b23939933 UnixOperatingSystem.st --- a/UnixOperatingSystem.st Tue Jun 09 14:06:26 1998 +0200 +++ b/UnixOperatingSystem.st Tue Jun 09 14:26:56 1998 +0200 @@ -3033,10 +3033,14 @@ ** first: dup filedescriptors */ for (i = 0; i < nfd; i++) { - if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) && - __intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i - ) { - dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i); + OBJ fd; + int rslt; + + fd = __ArrayInstPtr(fdArray)->a_element[i]; + if (__isSmallInteger(fd) && (__intVal(fd) != i)) { + do { + rslt = dup2(__intVal(fd), i); + } while ((rslt < 0) && (errno == EINTR)); } } /* @@ -3051,8 +3055,11 @@ ** third: close filedescriptors */ for (i = 0; i < nclose; i++) { - if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) { - close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i])); + OBJ fd; + + fd = __ArrayInstPtr(closeFdArray)->a_element[i]; + if (__isSmallInteger(fd)) { + close(__intVal(fd)); } } if (newPgrp == true) { @@ -5564,6 +5571,52 @@ !UnixOperatingSystem class methodsFor:'ipc support - UNIX'! +makePTYPair + "make a pipe, return array with two filedescriptors on success, + nil on failure. + This is a lowLevel entry, not for public use. + See ExternalStream>>makePipe for a more user-friendly, public interface." + + |fdS fdM| + +%{ +#ifdef IRIX +/* #include /* */ +/* #include /* */ + + int _fdM, _fdS; + char *line; + + /* + * Find a pseudo tty to use and open both sides. + * filedes[0] receives the master file descriptor while filedes[1] + * receives the slave. The master is opened with O_NDELAY as commonly + * needed in daemons such as rlogind and telnetd. + */ + + line = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0); + if ((line != 0) && (_fdM >= 0)) { + printf("opening slave side %s\n", line); + _fdS = open(line, O_RDWR); + if (_fdS < 0) { + (void)close(_fdM); + _fdS = _fdM = -1; + } + } else { + _fdM -1; + } + if ((_fdM >= 0) && (_fdS >= 0)) { + fdM = __MKSMALLINT(_fdM); + fdS = __MKSMALLINT(_fdS); + } +#endif +%}. + fdM notNil ifTrue:[ + ^ Array with:fdM with:fdS. + ]. + ^ nil +! + makePipe "make a pipe, return array with two filedescriptors on success, nil on failure. @@ -8100,6 +8153,6 @@ !UnixOperatingSystem class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.5 1998-06-05 17:10:27 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.6 1998-06-09 12:26:56 cg Exp $' ! ! UnixOperatingSystem initialize!