---
name: "__pmAddIPC"
section: "3"
platform: "linux"
package: "libpcp3-dev"
version: "6.0.3-1.1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/__pmAddIPC"
---

# \_\_pmAddIPC(3)

IPC version infrastructure support

## NAME

**\_\_pmAddIPC**, **\_\_pmLookupIPC**, **\_\_pmFdLookupIPC**, **\_\_pmOverrideLastFd**, **\_\_pmPrintIPC**, **\_\_pmResetIPC** - IPC version infrastructure support

## C SYNOPSIS

**#include "pmapi.h"**\
 **#include "libpcp.h"**

**int \_\_pmAddIPC(int** *fd***, \_\_pmIPC** *ipc***);**\
 **int \_\_pmLookupIPC(\_\_pmIPC \*\****ipcp***);**\
 **int \_\_pmFdLookupIPC(int** *fd***, \_\_pmIPC \*\****ipcp***);**\
 **void \_\_pmOverrideLastFd(int** *fd***);**\
 **void \_\_pmPrintIPC(void);**\
 **void \_\_pmResetIPC(int** *fd***);**

**cc ... -lpcp**

## CAVEAT

This documentation is intended for internal Performance Co-Pilot (PCP) developer use.

These interfaces are not part of the PCP APIs that are guaranteed to remain fixed across releases, and they may not work, or may provide different semantics at some point in the future.

## DESCRIPTION

IPC channels throughout the distributed PCP framework are affected by the PCP 2.0 (and later) PDU changes.  These functions are the interface to the libpcp IPC connection management global data.  This data consists of a hash table of \_\_pmIPC structures (indexed by file descriptor) and a cached, most-recently-used file descriptor.

Newly created IPC channels must be registered with the hash table using **\_\_pmAddIPC**, such that the PDU sending and decoding routines can determine whether they need to perform any PDU version translations or not, for backward compatibility with previous the PCP 1.x IPC protocol.

**\_\_pmLookupIPC** and **\_\_pmFdLookupIPC** both provide handles to the \_\_pmIPC structure associated with the given file descriptor, as previously established by a call to **\_\_pmAddIPC**. The difference between the two is that one allows an explicit file descriptor lookup, and the other uses the cached, most-recently-used file descriptor. So **\_\_pmLookupIPC** actually calls **\_\_pmFdLookupIPC** using this cached file descriptor as the argument.  The justification for having both is that in some places it is not possible to use **\_\_pmFdLookupIPC** (which is preferred), since at that particular level of the PMAPI a file descriptor is not available (see the \_\_pmDecodeError code for an example).

The **\_\_pmOverrideLastFd** is an escape mechanism for use in those situations where the last PDU fetch did not go through the usual channels (ie. \_\_pmGetPDU), so as to ensure that the cached file descriptor is the correct file descriptor for the PDU which is currently being processed.  This will typically be used for archive PDU processing or where version information is not available for a given file descriptor (eg. immediately prior to a PDU version exchange).

**\_\_pmPrintIPC** is a useful debugging routine for displaying a table mapping all currently registered file descriptors to their associated PDU version numbers.  Unused entries in this table should display the value zero in the version column.

**\_\_pmResetIPC** resets the version information associated with the given file descriptor to some known (invalid) number.  Subsequent lookups on this file descriptor will return an UNKNOWN\_VERSION embedded within the \_\_pmIPC structure.

## DIAGNOSTICS

A negative return value from **\_\_pmLookupIPC** indicates that the requested file descriptor is not registered in the hash table. This typically indicates closure of an IPC channel, so PM\_ERR\_IPC is returned if this is the case.

## SEE ALSO

[**PMAPI**(3)](/PMAPI/3.md)
