clock_getcpuclockid Subroutine

Purpose

Accesses a process CPU-time clock.

Syntax

#include <time.h>
int clock_getcpuclockid(pid_t pid, clockid_t *clock_id);

Description

The clock_getcpuclockid subroutine 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 returns in clock_id.

If pid is zero, the clock_getcpuclockid subroutine returns the clock ID specified in clock_id of the CPU-time clock of the process making the call.

To obtain the CPU-time clock ID of other processes, the calling process should be root or have the same effective or real user ID as the process that owns the targetted CPU-time clock.

Parameters

Item Description
clock_id Specifies the clock ID of the CPU-time clock.
pid Specifies the process ID of the CPU-time clock.

Return Values

Upon successful completion, the clock_getcpuclockid subroutine returns 0; otherwise, an error code is returned indicating the error.

Error Codes

Item Description
ENOTSUP The function is not supported with checkpoint-restart processes.
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.