---
name: "pmsetprocessidentity"
section: "3"
platform: "linux"
package: "libpcp3-dev"
version: "4.3.2+really4.3.1-0.1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/pmSetProcessIdentity"
---

# pmsetprocessidentity(3)

set process user and group id

Part of [pmSetProcessIdentity(3)](/pmSetProcessIdentity/3.md).

## NAME

**pmSetProcessIdentity** - set process user and group id

## C SYNOPSIS

**#include \<pcp/pmapi.h\>**

**pmSetProcessIdentity(const char \****username***);**

**cc ... -lpcp**

## DESCRIPTION

**pmSetProcessIdentity** provides a platform-independent method to set the user id of a process to that matching *username*.

If possible (when the caller is already running as root) **pmSetProcessIdentity** will set the group id of the process to that of the matching user, e.g. using *username* and [**getpwnam**(3)](/getpwnam/3.md).

A return value of 0 indicates success, otherwise the return value is an error code that may be decoded with [**pmErrStr**(3)](/pmErrStr/3.md).

**pmSetProcessIdentity** is most often used in conjunction with [**pmGetUsername**(3)](/pmGetUsername/3.md) at process start up.

## SEE ALSO

[**getpwnam**(3)](/getpwnam/3.md), [**PMAPI**(3)](/PMAPI/3.md), [**pmErrStr**(3)](/pmErrStr/3.md), [**pmGetUsername**(3)](/pmGetUsername/3.md), **setgid**(3) and **setuid**(3).
