--- a/UnixOS.st Tue Jun 09 19:04:29 1998 +0200
+++ b/UnixOS.st Tue Jun 09 19:18:57 1998 +0200
@@ -5580,20 +5580,19 @@
|fdS fdM|
%{
+ /*
+ * Find a pseudo tty to use and open both sides.
+ * _fdM receives the master file descriptor while _fdS
+ * receives the slave. The master is opened with O_NDELAY as commonly
+ * needed in daemons such as rlogind and telnetd.
+ */
+
#ifdef IRIX5
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);
@@ -5606,11 +5605,91 @@
fdM = __MKSMALLINT(_fdM);
fdS = __MKSMALLINT(_fdS);
}
-#endif
+#endif /* IRIX5 */
+
+
+#ifdef LINUX
+# define PTY_TEMPL "/dev/ptyXX"
+# define PTY_1_CHARS "abcdepqrstuvwxyz"
+# define PTY_2_CHARS "0123456789abcdef"
+#endif /* LINUX */
+
+#ifdef solaris
+# define PTY_TEMPL "/dev/ptyXX"
+# define PTY_1_CHARS "pqr"
+# define PTY_2_CHARS "0123456789abcdef"
+#endif /* LINUX */
+
+#ifdef aix
+# define PTY_TEMPL "/dev/ptyXX"
+# define PTY_1_CHARS "pqr"
+# define PTY_2_CHARS "0123456789abcdef"
+#endif /* LINUX */
+
+#ifdef next3
+# define PTY_TEMPL "/dev/ptyXX"
+# define PTY_1_CHARS "pqr"
+# define PTY_2_CHARS "0123456789abcdef"
+#endif /* LINUX */
+
+#ifdef hpux
+# define PTY_TEMPL "/dev/ptyXX"
+# define PTY_1_CHARS "pqrs"
+# define PTY_2_CHARS "0123456789abcdef"
+#endif /* LINUX */
+
+
+#ifdef PTY_TEMPL
+#include <grp.h>
+ static char line[] = PTY_TEMPL;
+
+ register const char *cp1, *cp2;
+ int _fdM = -1, _fdS = -1, ttygid;
+ struct group *gr;
+
+ if ((gr = getgrnam("tty")) != NULL)
+ ttygid = gr->gr_gid;
+ else
+ ttygid = -1;
+
+ for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
+ line[sizeof(line)-1-2] = * cp1;
+
+ for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
+ line[5] = 'p';
+ line[sizeof(line)-1-1] = *cp2;
+
+ if ((_fdM = open(line, O_RDWR, 0)) == -1) {
+ if (errno == ENOENT) {
+ _fdM = _fdS = -1;
+ goto getOutOfHere; /* out of ptys */
+ }
+ } else {
+ line[5] = 't';
+ (void) chown( line, getuid(), ttygid );
+ (void) chmod( line, S_IRUSR|S_IWUSR|S_IWGRP );
+
+ if( (_fdS = open(line, O_RDWR, 0)) != -1 ) {
+ goto getOutOfHere;
+ }
+ (void) close( _fdM );
+ }
+ }
+ }
+ getOutOfHere: ;
+
+ if ((_fdM >= 0) && (_fdS >= 0)) {
+ fdM = __MKSMALLINT(_fdM);
+ fdS = __MKSMALLINT(_fdS);
+ }
+
+#endif /* PTY_TEMPL */
%}.
+
fdM notNil ifTrue:[
^ Array with:fdM with:fdS.
].
+
^ nil
!
@@ -8150,6 +8229,6 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/UnixOS.st,v 1.7 1998-06-09 13:51:38 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/UnixOS.st,v 1.8 1998-06-09 17:18:57 cg Exp $'
! !
UnixOperatingSystem initialize!
--- a/UnixOperatingSystem.st Tue Jun 09 19:04:29 1998 +0200
+++ b/UnixOperatingSystem.st Tue Jun 09 19:18:57 1998 +0200
@@ -5580,20 +5580,19 @@
|fdS fdM|
%{
+ /*
+ * Find a pseudo tty to use and open both sides.
+ * _fdM receives the master file descriptor while _fdS
+ * receives the slave. The master is opened with O_NDELAY as commonly
+ * needed in daemons such as rlogind and telnetd.
+ */
+
#ifdef IRIX5
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);
@@ -5606,11 +5605,91 @@
fdM = __MKSMALLINT(_fdM);
fdS = __MKSMALLINT(_fdS);
}
-#endif
+#endif /* IRIX5 */
+
+
+#ifdef LINUX
+# define PTY_TEMPL "/dev/ptyXX"
+# define PTY_1_CHARS "abcdepqrstuvwxyz"
+# define PTY_2_CHARS "0123456789abcdef"
+#endif /* LINUX */
+
+#ifdef solaris
+# define PTY_TEMPL "/dev/ptyXX"
+# define PTY_1_CHARS "pqr"
+# define PTY_2_CHARS "0123456789abcdef"
+#endif /* LINUX */
+
+#ifdef aix
+# define PTY_TEMPL "/dev/ptyXX"
+# define PTY_1_CHARS "pqr"
+# define PTY_2_CHARS "0123456789abcdef"
+#endif /* LINUX */
+
+#ifdef next3
+# define PTY_TEMPL "/dev/ptyXX"
+# define PTY_1_CHARS "pqr"
+# define PTY_2_CHARS "0123456789abcdef"
+#endif /* LINUX */
+
+#ifdef hpux
+# define PTY_TEMPL "/dev/ptyXX"
+# define PTY_1_CHARS "pqrs"
+# define PTY_2_CHARS "0123456789abcdef"
+#endif /* LINUX */
+
+
+#ifdef PTY_TEMPL
+#include <grp.h>
+ static char line[] = PTY_TEMPL;
+
+ register const char *cp1, *cp2;
+ int _fdM = -1, _fdS = -1, ttygid;
+ struct group *gr;
+
+ if ((gr = getgrnam("tty")) != NULL)
+ ttygid = gr->gr_gid;
+ else
+ ttygid = -1;
+
+ for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
+ line[sizeof(line)-1-2] = * cp1;
+
+ for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
+ line[5] = 'p';
+ line[sizeof(line)-1-1] = *cp2;
+
+ if ((_fdM = open(line, O_RDWR, 0)) == -1) {
+ if (errno == ENOENT) {
+ _fdM = _fdS = -1;
+ goto getOutOfHere; /* out of ptys */
+ }
+ } else {
+ line[5] = 't';
+ (void) chown( line, getuid(), ttygid );
+ (void) chmod( line, S_IRUSR|S_IWUSR|S_IWGRP );
+
+ if( (_fdS = open(line, O_RDWR, 0)) != -1 ) {
+ goto getOutOfHere;
+ }
+ (void) close( _fdM );
+ }
+ }
+ }
+ getOutOfHere: ;
+
+ if ((_fdM >= 0) && (_fdS >= 0)) {
+ fdM = __MKSMALLINT(_fdM);
+ fdS = __MKSMALLINT(_fdS);
+ }
+
+#endif /* PTY_TEMPL */
%}.
+
fdM notNil ifTrue:[
^ Array with:fdM with:fdS.
].
+
^ nil
!
@@ -8150,6 +8229,6 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.7 1998-06-09 13:51:38 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.8 1998-06-09 17:18:57 cg Exp $'
! !
UnixOperatingSystem initialize!