PipeStream.st
changeset 21791 cec9749a6781
parent 21231 985ae4f2c424
child 22440 a5f9b3aed756
equal deleted inserted replaced
21790:e2c2bf98f841 21791:cec9749a6781
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     5 	      All Rights Reserved
     3 	      All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
   222 
   220 
   223     "
   221     "
   224 	|p|
   222 	|p|
   225 
   223 
   226 	p := PipeStream bidirectionalFor:'cat -u'.
   224 	p := PipeStream bidirectionalFor:'cat -u'.
   227 	p nextPutAll:'Wer ist der Bürgermeister von Wesel'; cr.
   225 	p nextPutAll:'Wer ist der Bürgermeister von Wesel'; cr.
   228 	Transcript showCR:p nextLine.
   226 	Transcript showCR:p nextLine.
   229 	p close
   227 	p close
   230     "
   228     "
   231 
   229 
   232     "
   230     "
   614      for WIN, Linux, Solaris and probably any other UNIX"
   612      for WIN, Linux, Solaris and probably any other UNIX"
   615     buffered := false.
   613     buffered := false.
   616     hitEOF := false.
   614     hitEOF := false.
   617     binary := false.
   615     binary := false.
   618 
   616 
   619     osProcess := OSProcess new 
   617     osProcess := OSProcess new
   620                     command:aCommandString;
   618                     command:aCommandString;
   621                     directory:aDirectory.
   619                     directory:aDirectory.
   622 
   620 
   623     mode == #readwrite ifTrue:[
   621     mode == #readwrite ifTrue:[
   624         pipeArray := self class makeBidirectionalPipe.
   622         pipeArray := self class makeBidirectionalPipe.
   683     nullOutput notNil ifTrue:[
   681     nullOutput notNil ifTrue:[
   684         nullOutput close
   682         nullOutput close
   685     ].
   683     ].
   686 
   684 
   687     result ifTrue:[
   685     result ifTrue:[
   688         "successfull creation of subprocesss"
   686         "successful creation of subprocess"
   689         handle := myPipeEnd handle.
   687         handle := myPipeEnd handle.
   690         handleType := myPipeEnd handleType.
   688         handleType := myPipeEnd handleType.
   691         myPipeEnd unregisterForFinalization.    "make sure filedesciptor is not closed by finalizer"
   689         myPipeEnd unregisterForFinalization.    "make sure filedesciptor is not closed by finalizer"
   692         myPipeEnd := nil.
   690         myPipeEnd := nil.
   693     ] ifFalse:[
   691     ] ifFalse:[
   700         ^ self openError:lastErrorNumber.
   698         ^ self openError:lastErrorNumber.
   701     ].
   699     ].
   702 
   700 
   703     self registerForFinalization.
   701     self registerForFinalization.
   704 
   702 
   705     "Modified: / 23.4.1996 / 17:05:59 / stefan"
   703     "Modified: / 23-04-1996 / 17:05:59 / stefan"
   706     "Modified: / 28.1.1998 / 14:47:34 / md"
   704     "Modified: / 28-01-1998 / 14:47:34 / md"
   707     "Created: / 19.5.1999 / 12:28:54 / cg"
   705     "Created: / 19-05-1999 / 12:28:54 / cg"
       
   706     "Modified (format): / 12-06-2017 / 12:31:24 / mawalch"
   708 !
   707 !
   709 
   708 
   710 terminatePipeCommand
   709 terminatePipeCommand
   711     osProcess notNil ifTrue:[
   710     osProcess notNil ifTrue:[
   712         osProcess terminateGroup.
   711         osProcess terminateGroup.