Last updated at 5:10 am UTC on 10 March 2018
2018 OSProcess 4.6.6
The wiki pages of interest for the OSProcess package are
Use the latest version of OSProcess and CommandShell, and load both of them. Load both from SqueakMap. Please use the head (latest version) and ignore any Squeak version tags or warnings.
OSProcess and CommandShell are Squeak version independent, but there is no way to say that with SqueakMap.
A Cuis version and a Pharo version have been produced as well.
OSProcess Version 4.3.7 (November 24, 2008)
Contributed by Dave Lewis
Download OSProcess from OSProcessV4-3-7.sar
Version 4 supports Squeak 3.6 through 3.10 (and probably earlier versions as well).
The plugin for OSProcess is separate from the OSProcess package, and is distributed as OSProcessPlugin, XDisplayControlPlugin and AioPlugin.
To easily communicate with external OS processes, use class PipeableOSProcess, which is included in the separate CommandShell package.
OSProcess provides access to operating system functions, including pipes and child process creation. It is implemented using pluggable primitives in a shared library for Unix or Linux, and a DLL for Windows. The Smalltalk code, including the classes which implement pluggable primitives for Unix or Win32 operating system functions, may be loaded into any Squeak image, but the primitives are only useful on Unix and Windows systems. Placeholder classes are provided for MacOS, OS/2 and RiscOS, but are not yet implemented.
Version 4 supports 64-bit and 32-bit Squeak.
As of version 3, OSProcess provides limited support for Windows in addition to Unix/Linux.
See also: CommandShell which uses OSProcess to implement a Unix command shell and terminal window in Squeak. The Windows support is not as complete as that for Unix, but it is sufficient for running external Win32 programs from Squeak.
If you use OSProcess, you may also be interested in CommandShell, DirectoryPlugin, and IOHandle.
If you have an iPAQ handheld, check out http://www.reasonability.net/ipaq/.
Changes in 4.3.7 since 4.3.6:
- At system shutdown, break dependency between ThisOSProcess and the OSProcessAccessor. This is done explicitly at shutdown in order to prevent possible problems when an image is restarted on another platform type, in which case a new ThisOSProcess instance is created and the old instance could still have an unwanted dependency on an OSProcessAccessor (bug found by Andreas Raab).
- Add WindowsProcess>>waitForCommand: implementation by Keith Hodges.
- On OS X, display management methods (e.g. #recapitate) and methods that require them (e.g. #forkSqueak) will not work. This is because an equivalent to XDisplayControlPlugin is not yet available for OS X.
- Stability and functionality of OSProcess on OS X is uncertain, as I do not have a Mac system available for testing (thanks to all who have helped testing via email).
- On Windows, OSPipe is implemented, but an OSPipe cannot yet be set for nonBlocking reads or writes. Reading from an OSPipe with no data available will block the Squeak VM.
- On Windows, command pipelines for external commands are not yet implemented. CommandShell does work, and may be used for launching individual Windows programs as well as for the usual CommandShell internal commands and internal command pipelines. However, it is not yet possible to construct a pipeline of Windows programs.
- Forking a child Squeak, as in UnixProcess>>forkSqueak, results in two instances of Squeak which share a single changes file. This has no practical impact if one or the other of the Squeak processes exits without doing very much, but it would could result in a corrupted changes file if both Squeak instances do a lot of changes. Any problems can be avoided by having one of the Squeak instances save itself as a new version, so that each instance uses its own image and changes files.
- The connectToXDisplay method is probably dangerous from a security perspective.
Previous versions of OSProcess:
Version 4.3.6 (December 23, 2007) OSProcessV4-3-6.sar
- Add patch from Jon Hylands to avoid problem moving images between Unix and Windows.
Version 4.3.5 (December 22, 2007) OSProcessV4-3-5.sar
- Fix a concurrency problem in BufferedAsyncFileReadStream>>upToEndOfFile. This corrects intermittent failures detected in CommandShell test suite.
Version 4.3.4 (December 20, 2007) OSProcessV4-3-4.sar
- Update reference to #listLoadedModules to work in newer Squeak versions.
- Update some default path strings for use in CommandShell.
- Removed separate version string for AioEventHandler.
Version 4.3.3 (April 8, 2007) OSProcessV4-3-3.sar
- Provide backward compatibility with older versions of OSProcessPlugin.
- Fix bug in end of file test with older OSPP.
Version 4.3.2 (April 1, 2007) OSProcessV4-3-2.sar
- Remove unnecessary synchronization semaphore from BufferedAsyncFileReadStream.
- Implement BufferedAsyncFileReadStream>>upTo:
- Fix underscores.
- Changed startup processing to reinitialize current OS process when image moves from one platform to another (e.g. image from Windows moved to Unix).
- Check installed OSPP version before calling pthread primitive to avoid error message when using older plugin.
- Add AttachableFileStream>>setBlocking and AttacheableFileStream>>setNonBlocking convenience methods.
- Better synchronization of buffer in BufferedAsyncFileReadStream.
- Add #killCurrentChildrenAtExit and #killOnVmExit:withSignal to arrange for child processes to be terminated on VM exit even if normal shutdown processing does not occur.
- Add accessor methods for Unix setsid(), getpgid(), setpgid(), getpgrp(), setpgrp() session management functions.
- Add modifications to StandardFileStream to package.
- Lower the priority of event handler process for AioEventHander to prevent input buffer being overloaded whens service process cannot keep up with input stream.
Version 4.3 (January 2007) OSProcessV4-3.sar
- Changes to support a fully event-driven CommandShell.
- Add StandardFileStream modifications to package.
- Change from underscores to ':=' for assignments.
- Win32OSProcessPlugin.dll is no longer distributed in this package.
- Fix #isAtEndOfFile: and add AttachableFileStream>>atEnd to make use of the fixed method. OSPP 4.2 has a fixed primitive that will be used if available, otherwise OSP works around the old bug.
- Add a nil check to AttachableFileStream>>atEnd.
- Reinstate methods required for backward compabibility with older CommandShell. Add new methods to implement improved #atEnd behavior, and #upToEndOfFile for pipes.
- Add buffered async behavior to file streams.
- Update OSPipe for event driven input.
- Update file locking to fix a bug and provide better error handling.
- Add fail blocks to file lock methods (versus e.g. test for nil).
- Add pthread instance variable to UnixProcess to display the identity of the pthread in which the interpreter is executing.
- File unlocking could fail if Win32 file locking emulation is disabled. This release fixes the problem. The problem can be demonstrated by evaluating 'OSProcessAccessor emulateWin32FileLocking: false' then running the UnixProcessFileLockingTestCase tests (or the UnixProcessWin32FileLockingTestCase and UnixProcessUnixFileLockingTestCase tests that replace them).
- Changed #saveImageInBackground to use a better time stamped image name.
- Added #saveImageInBackgroundNicely to do a background image save at lower priority.
- Fixed #uniqueNameForSavedImage to use leading zeros in date fields.
- Turn off Win32 file locking by default.
- Add a UnixProcess example for background processing.
- Clean up logic on OSFileLock>>test.
- Add pthread accessor for UnixOSProcessAccessor (requires OSPP 4.0.2).
Version 4.0.1 (November 2005) OSProcessV4-0-1.sar
- Add #nice: to set scheduling priority of the Squeak VM process.
- Add #forwardSigUsr1 and #forwardSigUsr2.
- Add methods for restoring original signal handlers, e.g. #restoreSigUsr1.
Version 4.0 (October 2005) OSProcessV4-0.sar
- Added 64-bit support. With OSPP 4.0 or greater, runs on a 64 bit VM, image, and/or 64 bit hardware. Backward compatibility is maintained for 32 bit platforms and earler VMMaker distributions.
- Added AIO classes previously distributed as part of the AIO package.
- Updated #allTestResults to tolerate missing plugins, update test for session ID, and provide better console output and results file.
- Fixed bit rot in Win32 classes.
- Added support for OS threads in Win32.
- Added Windows process access methods for primitives in OSPP 4.0.
Version 3.2.5 (May 2005) OSProcessV3-2-5.sar
- Refactored file lock management to provide clearer distinction between locks on file regions versus locks on entire files. Includes updates contributed by Julian Fitzell, who provided unit tests and various improvements to the file lock code.
- Made various changes and additions to OSProcessAccessor and UnixOSProcessAccessor to harvest additional improvements by Julian, and bring released version of OSP into sync with what Avi is using for Seaside applications.
- Added OSProcess class>>allTestResults
- Added UnixProcess class>>saveImageInBackground
Version 3.2.4 (March 2005)OSProcessV3-2-4.sar
- Refactored file lock management to provide clearer distinction between locks on file regions versus locks on entire files.
- Included updates contributed by Julian Fitzell, who provided unit tests and various improvements to the file lock code.
Version 3.2.3 (March 2005)OSProcessV3-2-3.sar.
- Added support for KCP refactorings, in which a number methods were moved from SystemDictionary to SmalltalkImage. Backward compatibility is maintained for Squeak 3.6 and earlier.
- Changed class categories to work better with Monticello.
- Various minor cleanups and refactorings for file locking support.
- Added OSPipeprintOn: to avoid a problem that occurs when using the default Stream implementation.
- Updated #removeAllOSProcessAndCommandShellClassesFromSystem to handle new class categories.
Version 3.2.2 (February 2004)OSProcessV3-2-2.sar.
Changes in 3.2.2 since 3.2.1:
- Update for Squeak 3.7. In particular, recent improvements to TestRunner flushed out some timing problems in OSProcess (especially in sUnit tests for CommandShell) which are now corrected in the child process reaper UnixOSProcessAccessorgrimReaperProcess.
- Rewrote primFork methods in both OSProcess and OSPP. This version of OSProcess uses the new primitives in OSPP 3.3 but maintains backward compatibility with earlier OSPP versions (at least back to OSPP 3.1.1). The child process creation methods for Unix now make use of the generic UnixProcessAccessorforwardSignal: signal forwarding mechanism rather than having the signal handlers coded in the individual process creation and pipe creation primitives in OSPP.
- If OSPP is compiled with -D_REENTRANT, OSProcess will probably now work on OS X, except for display management which is required for forkSqueak and friends.
- Better platform awareness for OS X.
- Rewrote file lock Win32 compatibility.
- Add class FileRegion to support Win32 file lock compatibility.
Here is a copy of OSProcess 3.2.2 that loads with most of the interactive dialogs disabled. This is for inclusion into Lex's first Universes test. It is identical to the OSProcessV3-2-2.sar (see above) that is used for SqueakMap except for the modified load scripts.OSProcessV3-2-2-noChat.sar____
Version 3.2.1 (January 2004)OSProcessV3-2-1.sar(contains Unix file locking)
Version 3.2.1 supports Squeak 3.6.
- Added support for Unix file locking (see the UnixOSProcessAccessor "file locking" method category).
- Generalized the logic for platform selection and added MacOS Unix/non-Unix conditions.
- Changed forkSqueak methods to fail gracefully if display management is not available.
- Removed obsolete method #primForkHeadlessSqueak.
- Fixed return value of #flushXDisplay.
- Some things are rumored to work on Mac OS X using the Unix VM.
The OSProcessPlugin (OSPP) is now distributed as a separate SqueakMap package, as is the new XDisplayControlPlugin package. The previous released version of OSP was 3.1 (version number 3.2 referred to an unleased version of OSP that was used for OS/X compatibility testing).
Version 3.1 (August 2003)
Version 3.0.6 (July 2003)
Version 2.7 (January 6, 2002)
Version 2.6 (December 8, 2001)
Version 2.5 (November 22, 2001)
Version 2.4 (October 20, 2001)
Version 2.3 (July 2, 2001)
Version 2.2 (May 27, 2001)
Note: Some browsers may drop the ".gz" file name suffix when you download. If this happens, just rename the file back to OSProcessV2-2.cs.gz on your local system.
OSProcess for Unix Squeak - Version 2.1 (May 5, 2001)
OSProcess for Unix Squeak - Version 2.0 (March 11, 2001)
Download these files:
Changes in 2.0 since 1.5:
- ExternalUnixProcess now has interesting instance variables, and knows how to execute commands in an external shell.
- ConnectedUnixProcess provides IO to child processes (such as shells) from Squeak, and provides a framework for command pipelines.
- Shell implements a basic command shell in Smalltalk, with file name globbing and other basics to eliminate the need for /bin/sh.
- Merged functionality of ShellProxy into ConnectedUnixProcess. Eliminated ShellProxy.
- Better implementation of UnixProcess class>makeVmIn: with error output of the Unix make returned to Squeak. Convenient for building plugins or new VMs without ever leaving Squeak. Be sure to check outVMMakerbyTim Rowledgealso.
- Changed UnixOSProcessPlugin to close all unneeded file handles (including sockets) prior in a child process. This eliminates some flakey behavior in child processes connected to Squeak by pipes, which failed to exit at expected times due to the old file descriptors remaining open. The #primitiveForkAndExecClosingAll method replaces the previous #primitiveForkAndExec for this. An attempt is made to maintain backward compatibility for images running on a VM with the old plugin.
- Improved handling of death of child. Added sigchld and sigpipe restore for child in a fork(). Cleaned up the sigpipe handler.
- Refactored and improved use of OSPipe.
- IOHandle (dtl) andVMMaker(tpr) supported but not required.
- Last but not least: The verbosity of Squeak and the complexity of Unix, all in one hard to use package. Amaze your friends and confound your enemies by evaluating incomprehensible expressions like this: "((Shell command: 'ps') | 'grep squeak' | 'cut -c16-100') output"
Download version 1.5 fromhttp://swiki.gsug.org:8080/sqfixes/1242.htmlChanges in 1.5 since 1.4:
- Updated support for IOHandle.
- General cleanup of UnixOSProcessAccessor and UnixOSProcessPlugin.
- Cleaned up #update: in UnixProcess. - UnixOSProcessAccessor now adds itself to the system startup list, and properly notifies its dependents following an image restart (distinguishes between a cold start and an image save so that UnixProcess can decide what to do with its child process dictionary).
- Subclassed OSProcessAccessor from Model rather than Object.
Help wanted: Concrete class implementations for Windows, Mac, etc. This should be easier now that FFI callouts are available. Anyone care to help?
Download version 1.4 fromhttp://swiki.gsug.org:8080/sqfixes/1123.html
Changes in 1.4 since 1.3:
- Split UnixOSProcessAccessor into two classes. UnixOSProcessPlugin now contains the methods which can be translated to a C plugin library, and UnixOSProcessAccessor no longer contains the plugin code. Cleaned up some of the plugin code to minimize C compiler warnings for strict compilers.
- Added various improvements to child process handling, particularly across image restarts. Added a primitive to UnixOSProcessPlugin to allow Squeak to check if a child process still exists following an image restart. ExternalOSProcess proxies now do a better job of keeping track of the external OS processes which they represent.
- Added UnixProcess class>makeVM utility for rebuilding the VM from a running Squeak session.
Download version 1.3 fromhttp://swiki.gsug.org:8080/sqfixes/1032.htmlThis version is updated for Squeak 2.8 and 2.9a. If you are building your Unix VM from the SourceForge repository, you should update your OSProcess to this new version.
The Unix plugin module name has been changed to UnixOSProcessPlugin.c. This is for consistency with other pluggable modules for the new pluggable VM.
The Smalltalk code is not backwardly compatible, because the primitive calling methods have been changed to use the new module name.
OSProcess for Unix Squeak - Version 1.2
Note to SourceForge VM folks: If you are using the pluginized VM, you will need to move the declaration of thisSession from sqFilePrims.c to sqXWindow.c. However, since sqFilePrims.c is one of the common modules exported from the image, I don't want to hack it on SF. Therefore, until I think of a better approach, you can fix your local sources as follows:
In sqFilePrims.c, change the declaration to:
extern int thisSession;
And in sqXWindow.c, add a declaration:
int thisSession = 0;
Download version 1.2 fromhttp://swiki.gsug.org:8080/sqfixes/982.html.
OSProcess for Unix Squeak - Version 1.1Updatedfor Squeak 2.7.
Files are contained in theosprocessv1-1-2.zipzip archive.
OSProcessV1-1-2.zip fixes an error in sqXWindow.c from the OSPRocessV1-1.zip version, and adds support for a "-headless" command line option for Unix. There are no other changes since OSProcessV1-1. dtl 2-April-2000.
OSProcess for Unix Squeak - Version 0.4
Release notes for version 0.4:Readme-OSProcessV0.4
Missing File (/squeak/uploads/osprocessv0.4.src.tgz) C source files
osprocess.4octo1251pm.cs Smalltalk source
osprocessv0-4-linux-2-2-10.tgz Linux binaries (lib6)
osprocessv0-4-linux-2-0-35.tgz Linux binaries (older system)
OSProcess for Unix Squeak - Version 0.3 (original release)
liReadme-OSProcessV0-3 Readme file for OSProcess
OSProcess.5July250pm.cs The change set - file this in to your image
Missing File (/squeak/uploads/OSProcessV0.3.tar.gz) Supporting files in gzipped tar format
Missing File (/squeak/uploads/OSProcessV0.3.zip) Same supporting files, but in zip format
Missing File (/squeak/uploads/sqXWindow.c.diff-OSProcessV0.3) For convenience, a diff of the sqXWindow.c changes
Current capabilities include:
Inspect the OS process in which Squeak is running: "OSProcess forThisOSProcess inspect"
liRead standard input, and write standard output and standard error streams.
liCreate operating system pipes and attach them to AttachableFileStream streams.
liCreate Unix child processes with protocol similar to (same as?) VisualWorks.
liClean up child processes automatically on exit (a Semaphore is set after receiving a SIGCHLD signal), with child exit status available in Squeak.
liStart a second Squeak in a child process, restarting the child from the last saved image file: "UnixProcess squeak"
liClone the running Squeak image, producing two nearly identical Squeaks running from the same object memory at the time of cloning: "UnixProcess forkSqueak"
liClone the running Squeak image, but with no display connection for the child: "UnixProcess forkHeadlessSqueakAndDo: aBlock"
liClone 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.
These notes are from the 0.3 release. Release 0.4 provides binaries for some systems, but building from source is left as an exercise
for the reader (at least until the next update of the Unix VM source code is available).
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 InstallBootstrap Install