[ANN] OSProcess version 0.3 for Squeak

David T. Lewis lewis at mail.msen.com
Wed Jul 7 03:52:55 UTC 1999


I have posted a new version of OSProcess for Squeak on the swiki at:
	http://minnow.cc.gatech.edu/squeak.708

I think that this version is fairly solid now. I'd appreciate feedback
from anyone who may be using it.

Here's the Readme file:
---------------------------------------------------------------------

OSProcess for Unix Squeak - Version 0.3

OSProcess provides access to operating system functions, including
pipes and child process creation. It is implemented using pluggable
primitives in a loadable module for Linux and will probably work on
most Unix systems. The Smalltalk code, including the classes which
implement pluggable primitives for Unix operating system functions,
may be loaded into any Squeak image, but the primitives are only useful
on Unix systems. Placeholder classes are provided for Mac and Windows,
but are not implemented here.

Current capabilities include:

- Inspect the OS process in which Squeak is running:
	"OSProcess forThisOSProcess inspect"

- Read standard input, and write standard output and standard error streams.

- Create operating system pipes and attach them to AttachableFileStream streams.

- Create Unix child processes with protocol similar to (same as?) VisualWorks.

- Clean up child processes automatically on exit (a Semaphore is set after
  receiving a SIGCHLD signal), with child exit status available in Squeak.

- Start a second Squeak in a child process, restarting the child from the
  last saved image file:
	"UnixProcess squeak"

- Clone the running Squeak image, producing two nearly identical Squeaks
  running from the same object memory at the time of cloning:
	"UnixProcess forkSqueak"

- Clone the running Squeak image, but with no display connection for the child:
	"UnixProcess forkHeadlessSqueakAndDo: aBlock"

- Clone the running Squeak image with no display connection, execute a block,
  and exit (similar to running a command from a Unix shell, except that the
  "command" is a Smalltalk block):
	"UnixProcess forkHeadlessSqueakAndDoThenQuit: aBlock"


If you are using a non-Unix platform, you can just file in the Smalltalk
files and have a look around. All of the code except for some minor patches
to the existing Unix support files is written in Smalltalk.

On Unix systems, some patches to sqXWindow.c (the C main program) are
required in order to permit access to the command line, environment,
stdio, stdout, and stderr. A patch file for this and for the makefile
changes is included here.

There are also changes to the interpreter support files to provide access
to SQFile data structures from pluggable primitives. The changes do not
effect the rest of the Squeak system, but they do require a one time
rebuild of the virtual machine and all the dynamically loaded modules.

The OSProcess primitives are implemented as pluggable primitives in a
loadable module. There are no changes to the base VM other than those
described above.


Installation
------------

To add OS Process support to Squeak on Linux (and probably other Unix
systems), follow these steps for the quick installation, or (for the
more patient and inquisitive) the bootstrap installation.

Quick install: For a quick installation on Unix, do the following.

1) Build a virtual machine from Ian's 2.4 sources. Make sure it
works, and back up your files before proceeding.

2) Change directory to the top of your 2.4 source tree, and unpack the
tar file or the zip archive, overlaying the existing files.

3) Rebuild the virtual machine. Copy the VM and the loadable modules
(*.so files) to their proper locations. If in doubt, put copies of the
loadable modules in the directory from which you run Squeak.

4) Run Squeak using the new VM and the new loadable modules. File in the
change set for OSProcess, and try the examples in OSProcess class and
UnixProcess class.


Bootstrap install: For a not-so-quick installation follow these steps.

1) Starting with your existing Squeak 2.4, make sure that you can build a new
virtual machine from sources. Back up your source code and image. Get a copy
of Ian's Unix source distribution if you have not already done so. Build
a VM and any loadable modules (*.so files), and make sure that they work
on your system.

2) Make sure you can build a VM with an interp.c which you generate from
Squeak. First generate a new interp.c from your Squeak image
("Interpreter translate: 'interp.c' doInlining: true"), then copy it into
your source tree and repeat step 1 (use the sqcat utility to copy the
file if your Squeak did not write the files using Unix line end conventions).

3) If step 2 fails to link due to unresolved symbols ioSetDisplayMode and
ioHasDisplayDepth, then add dummy functions for them. This is most easily
done by concatenating the file fix.c in this directory to the end of your
new interp.c, then repeating step 2. This resolves a bug in the Squeak 2.4
release, which was missing code for a couple of new primitives.

4) Patch your sqXWindow.c file using the supplied sqXWindow.diff (or
simply replace it with the sqXWindow.c in this directory). Rebuild your
VM once more to verify that your sqXWindow.c patch works.

5) Add a directory in your Squeak source tree in parallel with the
other pluggable modules, and call it ./src/UnixOSProcessAccessor
(currently you should also have ./src/SoundCodecPrims and ./src/Squeak3D
in your source tree). Also make a subdirectory for the new plugin in
the directory for your machine architecture
(./i386-linux-2.0.35/UnixOSProcessAccessor on my machine).
Edit your ./src/GNUmakefile (the one in your ./src directory, not
../GNUmakefile), and edit line 102 to add UnixOSProcessAccessor to the
list of plugins to be built, like this:

PLUGINS:=     SoundCodecPrims Squeak3D UnixOSProcessAccessor

6) Start Squeak, and file in the change set OSProcess.5July250pm.cs. This
will load all the new classes, as well as the changes to the interpreter
support files. Save your image.

7) Write out a new set of interpreter support files using
"InterpreterSupportCode writeSupportFiles". This will generate new
C files and headers with the changes needed to support access to SQFile
data structures in the pluggable primitives.

8) Write out the C source code for the UnixOSProcessAccessor module using
"UnixOSProcessAccessor translate: 'UnixOSProcessAccessor.c' doInlining: true".
See the comment in UnixOSProcessAccessor>>moduleName.

8) Copy the new files into your Squeak source tree (using the sqcat
utility if needed for Unix line end conventions).

9) Move the UnixOSProcessAccessor.c source file from
../src/UnixOSProcessAccessor.c into its subdirectory as
../src/UnixOSProcessAccessor/UnixOSProcessAccessor.c.
Likewise, move the file ./src/sqGSMCodecPlugin.c to
../src/SoundCodecPrims/sqGSMCodecPlugin.c so that it will be in its
correct subdirectory.

10) Run "make" to rebuild the VM and all the loadable modules. Move the
executable (i386-linux-2.0.35 on my system) to wherever you want the
VM to be located.

11) Copy the loadable module files (*.so), including the new
UnixOSProcessAccessor.so loadable module, from the machine architecture
directory (./i386-linux-2.0.35 on my machine) to the directory where
your Squeak loadable modules live. At this point, you have a working
VM with access to the UnixOSProcessAccessor plugin primitives.

12) Restart your image. Try the examples in OSProcess class and UnixProcess
class.

13) Let me know what you think. Suggestions for making this work on other
Unix flavors, and (better yet) other operating systems would be most welcome.

Mon Jul  5 17:42:43 EDT 1999 Dave Lewis
lewis at mail.msen.com
Linux dtlewis 2.0.35 #3 Fri Jan 1 17:22:57 EST 1999 i586 unknown





More information about the Squeak-dev mailing list