Process.st
changeset 19377 fca073527bd3
parent 19297 674bdfe7b7ed
child 19380 266a598cc12c
equal deleted inserted replaced
19376:5dc7266efb72 19377:fca073527bd3
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1992 by Claus Gittinger
     2  COPYRIGHT (c) 1992 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
  2133     ].
  2131     ].
  2134     var value:aValue.
  2132     var value:aValue.
  2135     ^ aValue
  2133     ^ aValue
  2136 !
  2134 !
  2137 
  2135 
       
  2136 stderr
       
  2137     "the processes stderr.
       
  2138      By default, this is Stderr, but it can be overwritten
       
  2139      (for example to redirect a thread's error output to some other place"
       
  2140      
       
  2141     ^ self environmentAt:#Stderr ifAbsent:Stderr
       
  2142 
       
  2143     "
       
  2144      Processor activeProcess stdout
       
  2145     "
       
  2146     
       
  2147     "
       
  2148      |out sema|
       
  2149      
       
  2150      out := WriteStream on:''.
       
  2151      sema := Semaphore new.
       
  2152      [
       
  2153         Processor activeProcess environmentAt:#Stdout put:out.
       
  2154         'hello world' printCR.
       
  2155         sema signal.
       
  2156      ] fork. 
       
  2157      sema wait.
       
  2158      Transcript showCR:('output was: ''',out contents,'''').
       
  2159     "
       
  2160 !
       
  2161 
       
  2162 stdin
       
  2163     "the processes stdin.
       
  2164      By default, this is Stdin, but it can be overwritten
       
  2165      (for example to redirect a thread's input from some other place"
       
  2166      
       
  2167     ^ self environmentAt:#Stdin ifAbsent:Stdin
       
  2168 !
       
  2169 
       
  2170 stdout
       
  2171     "the processes stdout.
       
  2172      By default, this is Stdout, but it can be overwritten
       
  2173      (for example to redirect a thread's output to some other place"
       
  2174      
       
  2175     ^ self environmentAt:#Stdout ifAbsent:Stdout
       
  2176 !
       
  2177 
  2138 threadVariableValueOf:aKey
  2178 threadVariableValueOf:aKey
  2139     "return the value of a thread local variable, or nil if no such variable exists"
  2179     "return the value of a thread local variable, or nil if no such variable exists"
  2140 
  2180 
  2141     ^ self environmentAt:aKey ifAbsent:nil
  2181     ^ self environmentAt:aKey ifAbsent:nil
  2142 
  2182 
  2143     "
  2183     "
  2144      see example in withThreadVariable:boundTo:do:
  2184      see example in withThreadVariable:boundTo:do:
  2145 
  2185 
  2146     "
  2186     "
       
  2187 !
       
  2188 
       
  2189 transcript
       
  2190     "the processes transcript.
       
  2191      By default, this is Transcript, but it can be overwritten
       
  2192      (for example to redirect a thread's output to some other place"
       
  2193      
       
  2194     ^ self environmentAt:#Transcript ifAbsent:[self stderr]
  2147 !
  2195 !
  2148 
  2196 
  2149 withThreadVariable:variableNameSymbol boundTo:aValue do:aBlock
  2197 withThreadVariable:variableNameSymbol boundTo:aValue do:aBlock
  2150     "evaluate a block with the threadLocalVariable being bound to aValue;
  2198     "evaluate a block with the threadLocalVariable being bound to aValue;
  2151      undo the variable binding afterwards."
  2199      undo the variable binding afterwards."