Subject: Re: popen reentrant (was Re: SA/pthread and vfork)
To: Christian Limpach <chris@pin.lu>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: tech-kern
Date: 09/12/2003 16:41:58
Christian Limpach <chris@pin.lu> writes:

> The appended patch should make popen()/pclose() reentrant.  It adds a
> lockfile for access to the pidlist and it prevents concurrent pclose/fclose
> calls on the descriptors in the pidlist from interfering with the child
> closing those descriptors.

(Man, I had no idea that popen()/pclose() went through all these
contortions. Yuck.)

Why is this using a rwlock instead of a mutex, since it never uses the
lock in read-only mode?

What's the reason for caching the file descriptor numbers of all pipes
in the pidlist? It's okay to use fileno(); FLOCKFILE()/FUNLOCKFILE()
are recursive locks.

        - Nathan