#include <unistd.h>

int setuid(uid_t uid);


Declared, not implemented


IEEE Std 1003.1-2017


If the process has appropriate privileges, setuid() shall set the real user ID, effective user ID, and the saved set-user-ID of the calling process to uid.

If the process does not have appropriate privileges, but uid is equal to the real user ID or the saved set-user-ID, setuid() shall set the effective user ID to uid; the real user ID and saved set-user-ID shall remain unchanged.

The setuid() function shall not affect the supplementary group list in any way.

Return value#

Upon successful completion, 0 shall be returned. Otherwise, -1 shall be returned and errno set to indicate the error.


The setuid() function shall fail, return -1, and set errno to the corresponding value if one or more of the following are true:

  • EINVAL - The value of the uid argument is invalid and not supported by the implementation.

  • EPERM - The process does not have appropriate privileges and uid does not match the real user ID or the saved set-user-ID.



Known bugs#


See Also#

  1. Standard library functions

  2. Table of Contents