Subject: getpwent_r()
To: None <current-users@netbsd.org>
From: John Nemeth <jnemeth@victoria.tc.ca>
List: current-users
Date: 03/31/2005 23:36:34
     libedit uses getpwent() to enumerate all users starting with a
particular string.  I think this means that we are going to need a
getpwent_r() function.  Solaris 8 has one that looks like this:

     struct passwd *getpwent_r(struct passwd *pwd, char  *buffer,
     int buflen);

     For enumeration in multithreaded applications, the  position
     within  the enumeration is a process-wide property shared by
     all threads. The setpwent() function may be used in  a  mul-
     tithreaded  application  but resets the enumeration position
     for all threads.  If multiple threads  interleave  calls  to
     getpwent_r(), the threads will enumerate disjoint subsets of
     the password database.

libedit also uses setpwent() and endpwent() which presents another
problem.  I don't see any simple solutions to the enumeration position
problem, so we'll probably just have to document that it does this.