class: TerminalSession
authorClaus Gittinger <cg@exept.de>
Mon, 08 Jul 2013 00:16:02 +0200
changeset 3040 c455569df459
parent 3039 2f36acd9c8b2
child 3041 563f38b0db89
class: TerminalSession class definition added: #ptyName changed: #createTerminalConnectionAndSetupWith:
TerminalSession.st
--- a/TerminalSession.st	Sun Jul 07 21:34:53 2013 +0200
+++ b/TerminalSession.st	Mon Jul 08 00:16:02 2013 +0200
@@ -4,7 +4,7 @@
 	instanceVariableNames:'inStream outStream errStream readerProcess shellPid shellCommand
 		shellDirectory readerDelay pluggableCheckBeforeReadAction
 		pluggableProcessInputAction execFDArray stxToStdinPipe
-		stdOutToStxPipe pty'
+		stdOutToStxPipe pty ptyName'
 	classVariableNames:'Debug'
 	poolDictionaries:''
 	category:'Views-TerminalViews'
@@ -63,6 +63,10 @@
     ^ pty
 !
 
+ptyName
+    ^ ptyName
+!
+
 shellCommand
     ^ shellCommand
 !
@@ -122,7 +126,7 @@
 createTerminalConnectionAndSetupWith:setupBlock
     "create a terminal conenction (pseudo terminal or pipe)"
 
-    |slaveFD master|
+    |slaveFD master slave ptyTriple|
 
     OperatingSystem isMSWINDOWSlike ifTrue:[
         "use two pipes to COMMAND.COM"
@@ -151,22 +155,28 @@
         inStream  := stxToStdinPipe at:2.
     ] ifFalse:[
         "Use a pseudo-tty"
-        pty := OperatingSystem makePTY.
-        pty isNil ifTrue:[
+        ptyTriple := OperatingSystem makePTY.
+        ptyTriple isNil ifTrue:[
             self warn:'Cannot open pty.'.
             ^ self.
         ].
 
+        ptyName := ptyTriple at:3.
 
         "/ pty at:1 is the master;
         "/ pty at:2 is the slave
-        master := NonPositionableExternalStream forReadWriteToFileDescriptor:(pty at:1).
+        master := NonPositionableExternalStream forReadWriteToFileDescriptor:(ptyTriple at:1).
         master buffered:false.
 
+        slave := NonPositionableExternalStream forReadWriteToFileDescriptor:(ptyTriple at:2).
+        slave buffered:false.
+
+        pty := { master . slave }.
+
         inStream := outStream := master.
         setupBlock value.
         "/ fork a shell process on the slave-side
-        slaveFD := (pty at:2).
+        slaveFD := (ptyTriple at:2).
         execFDArray := Array with:slaveFD with:slaveFD with:slaveFD.
     ].
 !
@@ -494,11 +504,11 @@
 !TerminalSession class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/TerminalSession.st,v 1.4 2013-07-07 19:34:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/TerminalSession.st,v 1.5 2013-07-07 22:16:02 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/TerminalSession.st,v 1.4 2013-07-07 19:34:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/TerminalSession.st,v 1.5 2013-07-07 22:16:02 cg Exp $'
 ! !