---
name: "__pmCleanMapDir"
section: "3"
platform: "linux"
package: "pcp"
version: "7.2.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/__pmCleanMapDir"
---

# \_\_pmCleanMapDir(3)

remove old files from a map directory

## NAME

**\_\_pmCleanMapDir** - remove old files from a map directory

## C SYNOPSIS

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

**int \_\_pmCleanMapDir(const char \****dirname***,** **const char \****special***);**

**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

[**pmlogger**(1)](/pmlogger/1.md) and [**pmie**(1)](/pmie/1.md) maintain directories of map files that provide a mapping from a [**pmlogger**(1)](/pmlogger/1.md) or [**pmie**(1)](/pmie/1.md) process id (PID) to important parameters of those processes.

**\_\_pmCleanMapDir** removes \`\`dead'' files in these directories, specifically the directory entries in *dirname* should follow these rules, else **\_\_pmCleanMapDir** will remove them:

- \+

  the name should be numeric, else it should be equal *special* (if *special* is not NULL)

- \+

  for a numeric directory entry it should be a regular file and the name should be the PID of a running process

- \+

  for a match on *special* the directory entry should be a symbolic link and the last component of the link should be the ASCII encoding of the PID of a running process

Before any of these checks are done, **\_\_pmCleanMapDir** checks that *dirname* is indeed a directory, and the user id and group id of the caller match the user id and group id of *dirname*.

## RETURN VALUES

If a serious error occurs, **\_\_pmCleanMapDir** returns a negative value suitable for reporting with [**pmErrStr**(3)](/pmErrStr/3.md). Otherwise the return value is the number of entries that have been removed.

## DIAGNOSTICS

Verbose diagnostics describing the actions of **\_\_pmCleanMapDir** will be reported on standard error of the debug option **misc** is set, e.g. via **-D misc** from the command line.

## SEE ALSO

[**pmdbg**(1)](/pmdbg/1.md), [**PMAPI**(3)](/PMAPI/3.md) and [**pmErrStr**(3)](/pmErrStr/3.md).
