setgroups() moved?

Jakub Jelinek jakub at
Wed Feb 23 16:12:08 UTC 2005

On Wed, Feb 23, 2005 at 05:06:07PM +0100, Kjartan Maraas wrote:
> Hi.
> It looks like this function moved? The man page says:
>        #include <sys/types.h>
>        #include <unistd.h>
> but it seems like it's really living in <grp.h>:
> [kmaraas at localhost xpl]$ grep setgroups /usr/include/*.h
> /usr/include/grp.h:extern int setgroups (size_t __n, __const __gid_t
> *__groups) __THROW;
> What's the right way of getting at this function? Preferrably in a way
> that works with other distros/OSes?

You haven't read the man page carefully:
       #include <sys/types.h>
       #include <unistd.h>

       int getgroups(int size, gid_t list[]);

       #include <grp.h>

       int setgroups(size_t size, const gid_t *list);

I.e. for getgroups you need sys/types.h and unistd.h and for setgroups
also grp.h.


More information about the fedora-devel-list mailing list