OSProcess?

David T. Lewis lewis at mail.msen.com
Tue Jul 25 02:58:15 UTC 2006


On Mon, Jul 24, 2006 at 11:11:44AM +0100, David Corking wrote:
> On 7/23/06, Alexandre Bergel <Alexandre.Bergel at cs.tcd.ie> wrote:
> >> Sorry, you can do this on unix based platforms, but not on windows.
> >> The Win32 version of OSPP is quite limited, and does not support
> >> the necessary command piping.
> 
> I am puzzled.  Why is piping necessary to run 'ls -l /etc ;' ?

Well, strictly speaking it isn't. But assuming that you want to make
use of the stdout output from the process that is running the /bin/ls
command (and similarly for stdin and stderr if these are of interest),
and assuming that you want to use Squeak for this rather than some
sort of tacky file copying arrangement, then the natural thing to
do is to pipe the output of /bin/ls into a pipe that you can read
from Squeak.

Class PipeableOSProcess (part of the CommandShell package, not
OSProcess per se) does this. When running on a Unix platform, Unix
pipes are used for the connections. The endpoints of the pipes are
FileStreams to Squeak, so you can read and write to the external
process in a reasonable way.

Win32 provides a similar mechanism for anonymous pipes, and OSPP
for Win32 can create these pipes. However, back when I was trying
to get this to work (using my Win95 development system I'm afraid),
I never really got the pipe mechanism to work reliably. The pipes
need to be non-blocking, and this was the part I could not get right.
Thus the pipes that PipeableOSProcess uses to connect the /bin/ls
program to your Squeak image are not available on Windows.

This is all perfectly doable stuff, I just don't happen to have
stumbled across enough motivation to make it happen. At the time,
I just got sick of rebooting my PC after every compile/link/crash
cycle, but that probably would no longer be an issue with a more
up-to-date Windows platform. I have not tried it though.

> >Arg...
> >So, I will hack something. I will probably do a small program in Peal
> >or Ruby that open a socket and wait for commands to be sent through
> >this socket. Any better idea welcomed...
> 
> I don't have any better ideas - but how about a worse one - how about
> compiling the unix OSProcess plugin (and unix vm) under cygwin?
> Perhaps it has never been done, but it may be fun to try.  Cygwin
> supports most of the unix/posix API.

Interesting idea. I can't say that it *wouldn't* work, and I'd certainly
like to hear about if it does :)

Dave




More information about the Squeak-dev mailing list