[squeak-dev] Error: ExternalUnixOSProcess not garbage-collected

David T. Lewis lewis at mail.msen.com
Thu Apr 17 11:07:16 UTC 2008


On Thu, Apr 17, 2008 at 01:17:08AM +0200, Winfried Jacobs wrote:
> Hello list,
> 
> I have a problem with  ExternalUnixOSProcess objects. In my squeak
> program I create them a lot, but they do not get garbage-collected, and
> after 1200 of  them are created, the program stops with an error:
> 'cannot create OS pipe' (error thrown in External pipe>>makePipe).
> 
> The following script demonstrates what is going on:
> 
> "### Script ###"
> 
>    1500 timesRepeat: [
>         p := PipeableOSProcess command: 'ls'.
> 
>            "these commands don't make a difference ... :"
>            "p  finalize."
>            "p release."
>            "p processProxy finalize."
>            "p close; closePipes."
> 
>        Transcript
>            show: PipeableOSProcess allInstances size;
>            show: '-';
>            show: ExternalUnixOSProcess allInstances size;
>            space.
>    ] .
> 
>    Smalltalk garbageCollect.
> 
> "### End of Script ###"

Hi Winfried,

To kill an external OS process, use #terminate.

The reason that you are running out of pipes is that the processes
are still running. If you do "p upToEnd" to read the output of the
command, it will complete normally. If you do "p terminate", it will
complete abnormally, and either way the pipes will be cleaned up.
The limit on number of open pipes (file handles) is imposed by the
operating system.

The reason that your external processes are not garbage collected is
that there is a reference to them in the process proxy for your
Squeak VM (OSProcess thisOSProcess allMyChildren). If you want to
clean this up, you can do "OSProcess thisOSProcess discardExitedChildren"
or "OSProcess thisOSProcess resetChildProcessDictionary". This is
not done automatically, which could become a problem if you have a
very long-running Squeak image I suppose.

Dave




More information about the Squeak-dev mailing list