---
name: "clock_getcpuclockid"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/clock_getcpuclockid"
---

# clock\_getcpuclockid(3)

access a process CPU-time clock

## NAME

**clock\_getcpuclockid** – access a process CPU-time clock

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<time.h\>**

*int*\

**clock\_getcpuclockid**(*pid\_t pid*, *clockid\_t \*clock\_id*);

## DESCRIPTION

The **clock\_getcpuclockid**() returns the clock ID of the CPU-time clock of the process specified by *pid*. If the process described by *pid* exists and the calling process has permission, the clock ID of this clock will be returned in *clock\_id*.

If *pid* is zero, the **clock\_getcpuclockid**() function returns the clock ID of the CPU-time clock of the process making the call, in *clock\_id*.

## RETURN VALUES

Upon successful completion, **clock\_getcpuclockid**() returns zero; otherwise, an error number is returned to indicate the error.

## ERRORS

The **clock\_getcpuclockid**() function will fail if:

- \[EPERM\]

  The requesting process does not have permission to access the CPU-time clock for the process.

- \[ESRCH\]

  No process can be found corresponding to the process specified by *pid*.

## SEE ALSO

[clock\_gettime(2)](/clock_gettime/2.md)

## STANDARDS

The **clock\_getcpuclockid**() function conforms to IEEE Std 1003.1-2001 (“POSIX.1”).

## HISTORY

The **clock\_getcpuclockid**() function first appeared in FreeBSD 10.0.

## AUTHORS

David Xu ⟨*davidxu@FreeBSD.org*⟩
