OSProcess 2.6 Author: David T. Lewis Previous released version: 2.5 Corresponding CommandShell version: 1.5 Solaris VM builders see "known bugs" below
Changes in 2.6 since 2.5: - Various changes to support CommandShell version 1.5. - Added nonBlocking mode to InternalPipe, and made InternalPipe behave more like an OSPipe. Added SUnit tests to verify pipe behavior.
OSProcess provides access to the external operating system from Squeak. A plugin is provided for Unix (and Linux) systems. OSProcess can be loaded on any platform, and placeholder classes are provided in the OSProcess hierarchy for other operating systems (Windows, Mac, OS/2, RiscOS), but support for these systems is not yet implemented.
You can: - Open a inspector on the operating system process in which Squeak is running (OSProcess thisOSProcess). - Read or write on the stdin, stdout, and stderr streams. - Access the command line, and get or set environment variables. - Fork and exec external programs, with control of the command line, environment, and stdin/stdout/stderr. - Open an inspector on a child operating system process created from Squeak, with run state and exit status of the child updated asynchronously. - Run an external command: OSProcess command: 'xeyes' - Connect directly to input and outputs of external commands: (ConnectedUnixProcess command: 'ls -l *') output - Create pipes and connect them to external processes. - Execute external command pipelines from Squeak: ((ConnectedUnixProcess command: 'ps') | 'grep squeak' | 'cut -c16-100') output - Fork an exact clone of the current running Squeak image (no image file) with parent and child Squeak processes proceeding from the same point in memory (UnixProcess forkSqueak). - Fork a Squeak using the disk based image (UnixProcess squeak). - Start a headless Squeak from the running Squeak image, giving it an expression to evaluate: (UnixProcess forkHeadlessSqueakAndDoThenQuit: [UnixProcess command: 'echo hello world']) - Tell the running image to go headless (UnixProcess decapitate), and reconnected the image with a window (UnixProcess recapitate). - Move the display to another computer on the network: (UnixProcess displayOnXServer: 'someOtherComputer') - Restart the VM on the fly (UnixProcess restartVirtualMachine). - Rebuild the VM, and restart Squeak with the new VM if the build was successful (UnixProcess makeVM). - Start your Swiki in a headless background process: (UnixProcess startSwiki: 'myswiki' onPort: 8081 loggingTo: 'log.txt')
OSProcessV2-6.cs is the main change set for OSProcess. OSProcess-sUnit-V2-6.cs contains SUnit tests (not required).
See the separate CommandShell change set for a Unix shell window which uses OSProcess.
The classes in OSProcess are:
Object OSProcess ExternalOSProcess ExternalMacOSProcess ExternalOS2Process ExternalRiscOSProcess ExternalUnixProcess ConnectedUnixProcess ExternalWindowsOSProcess ThisOSProcess MacProcess OS2Process RiscOSProcess UnixProcess WindowsProcess Stream OSPipe InternalPipe OSProcessAccessor MacOSProcessAccessor OS2OSProcessAccessor RiscOSProcessAccessor UnixOSProcessAccessor WindowsOSProcessAccessor InterpreterPlugin UnixOSProcessPlugin UnixOSProcessPluginDynamicThisSession UnixOSProcessPluginInterpreterGetThisSession UnixOSProcessPluginStaticThisSession
Known bugs in this version: - 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 probably result in a corrupted changes file if both Squeak instances do a lot of changes. I am leaving this as is for now, since a quick fix would require one of the Squeaks to save itself under an different image name. - The connectToXDisplay method is probably dangerous from a security perspective. - UnixOSProcessAccessor>>primitiveEnsetEnv uses the function unsetenv(), which is not available on Solaris (and possibly other systems). I do not know the portable equivalent of unsetenv(), so for now Solaris users will need to comment out the call to unsetenv() and rebuild the plugin. Other than failing the SUnit tests, commenting the function out has little practical impact.
I backed out of installing the earlier version when I got similar errors. What am I doing wrong here?
The CommandShell stuff installs without hiccups.
I rename the UnixOSProcessPlugin.so, restart Squeak and try filing it in.
I get a dialogue box:
System type is still used in code of class OSProcessor class. Is it OK to move it to undeclared?
Being cautious (and not being sure what "it" really refers to) I answer "no" and get a walkback soon afterwards:
This OSProcessAccessor is already defined in a subclass >> ClassBuilder (Object) error:
Any ideas welcome!
Cheers
John
On Sun, Dec 09, 2001 at 05:48:19AM +0000, John Hinsley wrote:
I backed out of installing the earlier version when I got similar errors. What am I doing wrong here?
The CommandShell stuff installs without hiccups.
I rename the UnixOSProcessPlugin.so, restart Squeak and try filing it in.
I get a dialogue box:
System type is still used in code of class OSProcessor class. Is it OK to move it to undeclared?
Being cautious (and not being sure what "it" really refers to) I answer "no" and get a walkback soon afterwards:
This OSProcessAccessor is already defined in a subclass >> ClassBuilder (Object) error:
It's perfectly OK to leave your UnixOSProcessPlugin.so in place when you load the new version of OSProcess. You can rebuild it if needed (although I made no the Unix plugin in this release).
Remove all of the OSProcess classes, and also the UnixOSProcessPlugin classes (four of them now) which are hidden in the VMConstruction-Plugins category. Reload everything from the new change sets, and everything should be fine. Well, almost everything; if you have any previously opened CommandShell windows, you may find that they have gotten confused by all of this surgury.
Sounds like something else I need to document...
Dave
On Sun, Dec 09, 2001 at 08:43:57AM -0500, David T. Lewis wrote:
On Sun, Dec 09, 2001 at 05:48:19AM +0000, John Hinsley wrote:
I backed out of installing the earlier version when I got similar errors. What am I doing wrong here?
<problem loading OSProcess into image with older version of OSProcess>
Remove all of the OSProcess classes, and also the UnixOSProcessPlugin classes (four of them now) which are hidden in the VMConstruction-Plugins category. Reload everything from the new change sets, and everything should be fine. Well, almost everything; if you have any previously opened CommandShell windows, you may find that they have gotten confused by all of this surgury.
Attached change set clobbers OSProcess with fewer keystrokes.
Dave
Thanks Dave
I got OSProcess V2.6 filed in OK, but realised I needed to recompile the Plugin to take advantage of it. I get a make error:
../src/UnixOSProcessPlugin/UnixOSProcessPlugin.c: In function `getThisSessionIde ntifier': ../src/UnixOSProcessPlugin/UnixOSProcessPlugin.c:320: parse error before `extern ' //(this is the section)
/* Note: This is hardcoded so it can be run from Squeak. The module name is used for validating a module *after* it is loaded to check if it does really contain the module we're thinking it contains. This is important! */
EXPORT(const char*) getModuleName(void) { return moduleName; }
static int getThisSessionIdentifier(void) { return (extern int) thisSession; }
static int halt(void) { ; }
It could simply be an issue of gcc version: gcc -v gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
and I am building it against Lex's 3.0 sources (I get a stack of errors where make on the 3.1 version expects all kinds of Sun headers, and getting rid of those, I run into gnuify errors....;-): if you think building against the later source would help, I'll give it a go.
Cheers
John
On Sun, Dec 09, 2001 at 04:13:39PM +0000, John Hinsley wrote:
Thanks Dave
I got OSProcess V2.6 filed in OK, but realised I needed to recompile the Plugin to take advantage of it. I get a make error:
static int getThisSessionIdentifier(void) { return (extern int) thisSession; }
Duh, sorry about that. I don't have time right now to fix and test it in the plugin class, but if you just hack this into your C file it will probably work.
static int getThisSessionIdentifier(void) { extern int thisSession; return thisSession; }
Or file in the attached change set which should do the same thing when you regenerate the plugin. This is *not* tested (sorry) but is probably OK. BTW, there are now three slightly different flavors of the Unix plugin. I'm using VMMaker for building. The plugin code you get attempts to match the rest of the build tree, but I botched this one.
Dave
Thanks Dave
hacking the .c file did the trick (but I'll file in the changesets in case I need them).
Wow, two problems solved in 10 minutes! Must quit while I'm ahead!
Thanks again
Cheers
John
squeak-dev@lists.squeakfoundation.org