OSProcess runs out of resources? (and other errors)

David T. Lewis lewis at mail.msen.com
Wed May 24 22:59:22 UTC 2000


David, Stefan:

I'm away from my Squeak system, so I can't check into any of
this for you right now, but a couple of notes that might help:

- I don't recall having done anything special to close pipes (just
a close() on the file handle, I think), which means there is a
good chance I didn't handle it right.

- I haven't ever had problems with this on Linux/FreeBSD, and to be
honest I didn't know that anyone was running OSProcess on Suns yet.
If you're curious and want to debug it, run the VM under gdb
and put in a breakpoint whatever primitive you are debugging.
If you think you're running out of file handles, you should be
able to see it happening.

- IOHandle is used conditionally because I normally have it in
my image, but don't expect other people to use it. IOHandle lets
you see the contents of SQFile data structures from Squeak, but
it's a hack and not really intended for general use. You can get
a copy from the swiki if you're interested.

- A word of caution: The VM does not have a handler for SIGPIPE,
which means that you can crash your VM if you do I/O to a pipe
connected to a dead process. Let me know if it's a problem for
you, as I have a fix in my development version of OSProcess.

HTH,
Dave

On Wed, May 24, 2000 at 01:52:20PM -0400, Pennell, David wrote:
> Stefan is using ConnectedProcess, which creates a 3 pipes,
> one each for stdin,stdout and stderr.
> 
> OSProcesses are finalized, but it looks like the 
> pipes are created directly in the VM and therefore owned by
> the Squeak process.  I see #primitiveMakePipe, but I don't
> see any way to remove them.  One of the paths for creating
> a pipe looks for class IOHandle and if it isn't present,
> returns a ByteArray instead.  Perhaps IOHandle includes
> finalization support for closing external handles?
> 
> -david
> 
> 
> > -----Original Message-----
> > From: Stefan Matthias Aust [mailto:sma at 3plus4.de]
> > Sent: Wednesday, May 24, 2000 1:19 PM
> > To: squeak at cs.uiuc.edu
> > Subject: OSProcess runs out of resources? (and other errors)
> > 
> > 
> > With the help of David Pennell, I was able to test the 
> > OSProcess package 
> > for Squeak on Solaris 7.  It's working fine, however, I can call an 
> > external program only for about 10 times.  Thereafter, I get 
> > strange errors.
> > 
> > I'd guess the system runs out of some resources, file handles 
> > or so.  This 
> > is very bad as I need to call it much more often.   I'd like 
> > to free the 
> > resources but I didn't find a method to clean up (or close) a 
> > ConnectedProcess (this is what I use right now).  Does 
> > anybody notice this 
> > and/or has a workaround?
> > 
> > Then I noticed that stdOut atEnd doesn't work.  I never 
> > returns true, even 
> > if stdOut next (correctly) answers nil.   This is bad as a 
> > couple of stream 
> > methods don'T work, for example #upToEnd.  I wrote a workaround by 
> > implementing that method in terms of next not using atEnd but 
> > still, that's 
> > probably a bug that must be fixed elsewhere.
> > 
> > It's also annoying that there's no automatic cr/lf 
> > conversion:  I simply 
> > implemented
> > 
> > next
> >    | n |
> >    ^(n _ super next) == Character lf
> >       ifTrue: [Character cr]
> >       ifFalse: [n]
> > 
> > but I think, this still a general smalltalk problem.  I also changed
> > 
> > cr
> >    self nextPut: Character lf
> > 
> > so that I can use the normal Smalltalk style of dealing with 
> > streams.  However, I know this is only a hardcoded solution 
> > for Unix.  When 
> > somebody implements the OSProcess system for other platforms, 
> > we need a 
> > more clever solution here.
> > 
> > But: Thank you for providing the code.  It's nevertheless very useful.
> > 
> > bye
> > --
> > Stefan Matthias Aust  //  Bevor wir fallen, fallen wir lieber auf
> > 
> 





More information about the Squeak-dev mailing list