PipeStream.st
changeset 16953 4fb3033a379f
parent 16579 3d51a7434f06
child 17077 8f4500d0df9e
equal deleted inserted replaced
16952:3e82aaac33d4 16953:4fb3033a379f
    59  */
    59  */
    60 #undef NEED_POPEN_WITH_VFORK
    60 #undef NEED_POPEN_WITH_VFORK
    61 
    61 
    62 /*
    62 /*
    63  * some systems (i.e. ultrix) use fork;
    63  * some systems (i.e. ultrix) use fork;
    64  * were better off with a popen based on vfork ...
    64  * we're better off with a popen based on vfork ...
    65  */
    65  */
    66 #ifdef NEED_POPEN_WITH_VFORK
    66 #ifdef NEED_POPEN_WITH_VFORK
    67 
    67 
    68 static int popen_pid = 0;
    68 static int popen_pid = 0;
    69 
    69 
   426 
   426 
   427     p := self readingFrom:aCommand.
   427     p := self readingFrom:aCommand.
   428     p isNil ifTrue:[^ nil].
   428     p isNil ifTrue:[^ nil].
   429 
   429 
   430     [
   430     [
   431         cmdOutput := p contentsAsString.
   431 	cmdOutput := p contentsAsString.
   432     ] ensure:[
   432     ] ensure:[
   433         p close.
   433 	p close.
   434     ].
   434     ].
   435     ^ cmdOutput
   435     ^ cmdOutput
   436 
   436 
   437     "
   437     "
   438      PipeStream outputFromCommand:'ls -l'
   438      PipeStream outputFromCommand:'ls -l'
   509     "low level close
   509     "low level close
   510      This waits for the command to finish.
   510      This waits for the command to finish.
   511      Use shutDown for a fast (nonBlocking) close."
   511      Use shutDown for a fast (nonBlocking) close."
   512 
   512 
   513     handle notNil ifTrue:[
   513     handle notNil ifTrue:[
   514         super closeFile.
   514 	super closeFile.
   515 "/        OperatingSystem isMSDOSlike ifTrue:[
   515 "/        OperatingSystem isMSDOSlike ifTrue:[
   516 "/            self terminatePipeCommand.
   516 "/            self terminatePipeCommand.
   517 "/        ].
   517 "/        ].
   518 
   518 
   519         handle := nil.
   519 	handle := nil.
   520         pid notNil ifTrue:[
   520 	pid notNil ifTrue:[
   521             "/ wait for the pipe-command to terminate.
   521 	    "/ wait for the pipe-command to terminate.
   522             self waitForPipeCommandWithTimeout:nil.
   522 	    self waitForPipeCommandWithTimeout:nil.
   523         ].
   523 	].
   524     ].
   524     ].
   525 
   525 
   526     "Modified: / 12.9.1998 / 16:51:04 / cg"
   526     "Modified: / 12.9.1998 / 16:51:04 / cg"
   527 ! !
   527 ! !
   528 
   528 
   793 
   793 
   794 terminatePipeCommand
   794 terminatePipeCommand
   795     |tpid|
   795     |tpid|
   796 
   796 
   797     (tpid := pid) notNil ifTrue:[
   797     (tpid := pid) notNil ifTrue:[
   798         OperatingSystem terminateProcessGroup:tpid.
   798 	OperatingSystem terminateProcessGroup:tpid.
   799         OperatingSystem terminateProcess:tpid.
   799 	OperatingSystem terminateProcess:tpid.
   800     ].
   800     ].
   801 !
   801 !
   802 
   802 
   803 waitForPipeCommandWithTimeout:seconds
   803 waitForPipeCommandWithTimeout:seconds
   804     "wait for the pipe command to terminate itself.
   804     "wait for the pipe command to terminate itself.
   815 ! !
   815 ! !
   816 
   816 
   817 !PipeStream class methodsFor:'documentation'!
   817 !PipeStream class methodsFor:'documentation'!
   818 
   818 
   819 version
   819 version
   820     ^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.116 2014-06-14 09:22:57 cg Exp $'
   820     ^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.117 2014-11-07 11:42:18 cg Exp $'
   821 !
   821 !
   822 
   822 
   823 version_CVS
   823 version_CVS
   824     ^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.116 2014-06-14 09:22:57 cg Exp $'
   824     ^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.117 2014-11-07 11:42:18 cg Exp $'
   825 ! !
   825 ! !
   826 
   826 
   827 
   827 
   828 PipeStream initialize!
   828 PipeStream initialize!