[squeak-dev] Using OSProcess

Eliot Miranda eliot.miranda at gmail.com
Sat Nov 20 18:52:20 UTC 2010


Hi David,

On Sat, Nov 20, 2010 at 9:07 AM, David T. Lewis <lewis at mail.msen.com> wrote:

> On Fri, Nov 19, 2010 at 03:56:26PM -0200, Casimiro de Almeida Barreto
> wrote:
> > Em 19-11-2010 15:39, Mike Hales escreveu:
> > > Thanks, that's just want I wanted. And thanks Sean for the tip on
> > > the http://forum.world.st/ index. That's pretty handy having all the
> > > lists together in one spot.
> > >
> > >
> > > Mike
> > >
> > > Mike Hales
> > > Engineering Manager
> > > KnowledgeScape
> > > www.kscape.com <http://www.kscape.com>
> > BTW, if you're running squeak over CogVM it wont work... there are
> > incompatibilities between OSProcess, CommandShell and OSProcessPlugin
> > and cog.
> >
> > Interesting enough, if I do:
> >
> > | str |
> >
> >     str := (PipeableOSProcess command: 'ls -l') upToEnd.
> >
> > It will return and empty ByteString but will fail to read output from
> > stdOut.
>
> This is just a timing glitch. Try this instead and I think you will
> get the results you want. This works on both Cog and the interpreter VM:
>
>  (PipeableOSProcess command: 'ls -l') upToEndOfFile
>
> Piping to and from an external process can be a bit tricky. A program
> like /bin/ls will exit only after you close the pipe to its standard
> input (the #command: method does this for you). After that pipe closes,
> the /bin/ls program will flush its standard output stream to the
> pipe that is connected back to Squeak. Some time after that, the
> data will become available for Squeak to read. When you do #upToEnd,
> you are reading all available data on that pipe, and if you happen
> to read it before it is all available, you get an empty string.
> The #upToEndOfFile keeps trying to read until the pipe is actually
> closed (when /bin/ls exits), so this makes sure you get all of the
> output data even when you are running on a really fast Cog VM :)
>
> >
> > Forking PipeableOSProcess won't work when using cog.
> >
> > like:
> >
> > ps := PipeableOSProcess forkHeadlessSqueakAndDoThenQuit: [ ... ]
> >
> > will fail crashing cog (memory fault). At least under linux.
>
> As far as I know, then only part of OSProcess/CommandShell that
> does not work in Cog is the #forkSqueak methods. Unfortunately,
> #forkSqueak is used extensively in the unit tests, so be careful
> about running those under Cog. But all other OSProcess and CommandShell
> functions seem to work fine in Cog.
>

Any idea what it is about forkSqueak that breaks Cog?

>
> You may get a warning dialog about AioPlugin not present. This is
> because the plugin was not included in the Cog VM, and you can
> safely ignore the warning.
>
> Dave
>

best
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20101120/59b3ac16/attachment.htm


More information about the Squeak-dev mailing list