[squeak-dev] Is there any way of reopening OSProcess thisOSProcess stdOut to a given FileStream?

David T. Lewis lewis at mail.msen.com
Tue May 19 01:28:39 UTC 2009


On Mon, May 18, 2009 at 11:35:56AM -0300, Casimiro de Almeida Barreto wrote:
> 
> Any suggestions on how reopen stdOut to a desired point other than the
> default?

Hi Casimiro,

I was looking into this just last night, and have gotten far enough so that
the following works, and I can verify that the Unix file descriptors are
properly duplicated for child processes to inherit correctly.

  OSProcess command: 'mkfifo myPipe'.
  fd := FileStream fileNamed: 'myPipe'.
  OSProcess thisOSProcess redirectStdOutTo: fd.
  OSProcess thisOSProcess redirectStdErrTo: fd.
  OSProcess thisOSProcess stdOut nextPutAll: 'hello '; flush.
  OSProcess thisOSProcess stdErr nextPutAll: 'world!'; flush.
  fd next: 11 ==> 'hello world'

This requires some updates to OSProcessPlugin (a primitive for the dup2()
system call) and to OSProcess. I'm not done yet, but I'll try to get this
cleaned up and posted by this weekend.

Dave




More information about the Squeak-dev mailing list