[squeak-dev] OSProcess left-over pipe handles?

Gerardo Richarte gera at corest.com
Fri Dec 11 22:51:38 UTC 2009


Andreas Raab wrote:
> Hi -
>
> Today I noticed that we're starting to accumulate lots of pipe handles
> on our servers when running for a while. I believe these are the
> results of OSProcess usage and I was wondering what the correct way to
> clean these up would be. lsof lists all of them just like here:

without going to see anything in squeak (so, maybe totally wrong),
usually when you call pipe() in unix, you then fork() and pass one of
the two descriptors to the child process. The common practice is to
close() the file descriptors passed to the child process. This has to be
done in the parent process after forking. Otherwise the parent keeps
open the end of the pipe() corresponding to the child.

Of course, after finishing you also hahve to close() the other end of
the pipe() in the parent. The child process usually dies, hence closing
all file descriptors. But, if the child doesn't die, then you have to be
careful to also close the file descriptors belonging to the parent, and
the proper way to do it is to close them just after forking, in the
child process... something like:

        pipe(&parentFd, &childFd);
        fork()

          parent: close(childFd)            child: close(parentFd)

          ...                                             ...

          close(parentFd)                      close(childFd)


    gera



More information about the Squeak-dev mailing list