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

# pmc\_configure\_logfile(3)

log file management

## NAME

**pmc\_configure\_logfile**, **pmc\_flush\_logfile**, **pmc\_writelog**, **pmc\_close\_logfile** – log file management

## LIBRARY

library “libpmc”

## SYNOPSIS

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

*int*\

**pmc\_configure\_logfile**(*int fd*);

*int*\

**pmc\_flush\_logfile**(*void*);

*int*\

**pmc\_writelog**(*uint32\_t userdata*);

*int*\

**pmc\_close\_logfile**(*void*);

## DESCRIPTION

The functions manage logging of [hwpmc(4)](/hwpmc/4.md) events.

Function **pmc\_configure\_logfile**() is used to turn on and turn off logging. If argument *fd* is a valid file handle returned by a prior call to [open(2)](/open/2.md) or [socket(2)](/socket/2.md) then performance events will be logged to the file corresponding to the specified handle. If the value of argument *fd* is -1 then logging will be stopped after any pending data is flushed.

Function **pmc\_flush\_logfile**() will force all log data queued inside the [hwpmc(4)](/hwpmc/4.md) driver to be written out.

Function **pmc\_writelog**() will append a log entry containing the value of argument *userdata* to the log file.

Function **pmc\_close\_logfile**() will flush all pending log data and close [hwpmc(4)](/hwpmc/4.md)'s side of the stream.

## RETURN VALUES

The **pmc\_configure\_logfile()** function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

## ERRORS

A call to **pmc\_configure\_logfile**() may fail with the following errors:

- \[EAGAIN\]

  The [hwpmc(4)](/hwpmc/4.md) driver was not able to create a helper process due to system limits being reached.

- \[EBUSY\]

  Function **pmc\_configure\_logfile**() was called with a log file already configured.

- \[EINVAL\]

  Function **pmc\_configure\_logfile**() was called with an argument of -1 without a log file being previously configured.

- \[ENOMEM\]

  The system encountered a memory shortage when servicing this request.

A call to **pmc\_flush\_logfile**() may fail with the following errors:

- \[EINVAL\]

  Function **pmc\_flush\_logfile**() was called without a log file being previously configured.

A call to **pmc\_writelog**() may fail with the following errors:

- \[EINVAL\]

  Function **pmc\_writelog**() was called without a log file being previously configured.

- \[ENOMEM\]

  The system encountered a memory shortage when servicing this request.

## SEE ALSO

[pmc(3)](/pmc/3.md), [hwpmc(4)](/hwpmc/4.md)
