setuid(3)

DESCRIPTION

Sets the process real and effective user IDs to uid, subject to the kernel's current‑credential rule.

SYNOPSIS

#include <unistd.h>

int setuid(uid_t uid);

RETURN VALUE

  • Returns zero, or -1 and sets errno.

ERRORS

  • -EINVAL
    • Uid cannot be represented by the direct ABI.
  • -EPERM
    • The requested transition is not allowed for the current effective UID.
  • -ESRCH
    • The calling process does not exist.

NOTES

The wrapper translates a negative direct result to -1 and errno.