PMPRINTF(3)

πŸ“¦
version 7.2.2 Β· 2 versions
, in arch rolling, centos-stream 10, fedora 43, fedora 44, ubuntu resolute, ubuntu stonking

πŸ’– PMPRINTF πŸ’–

okay bestie, sit down, hydrate, because we're talking about pmprintf and pmflush β€” the little duo from the PCP Library Functions Manual that prints your formatted output in a window or straight to standard error. it's giving "fprintf but make it ✨choices✨". no cap.


🌸 NAME 🌸

pmprintf, pmflush β€” print formatted output in a window or to standard error 🫢


✨ C SYNOPSIS ✨

#include <pcp/pmapi.h>

int pmprintf(const char *fmt, ... /*args*/);
int pmflush(void);

cc ... -lpcp

πŸ¦‹ DESCRIPTION πŸ¦‹

so the way this works, bestie: you take pmprintf and pmflush, you put them together, and they produce output in one of three places β€” an xconfirm(1) window, the standard error stream, or a file β€” and they do it in a manner similar to fprintf(3). iconic behaviour honestly.

the fmt argument is the one calling the shots for the conversion, formatting, and printing of the variable length args list. and which of those three output techniques you get? that's controlled via an environment variable, iykyk. πŸ‘‘

pmprintf appends the formatted message string to an internal buffer shared by the two routines, and it does not actually produce any output yet. it's just queueing the vibes. πŸ™ˆ

pmflush is the main character moment: it causes the internal buffer to be either displayed in a window, printed on standard error, or flushed to a file β€” and then the internal buffer gets cleared. periodt. πŸ’…


πŸ’€ DIAGNOSTICS πŸ’€

on successful completion, pmprintf returns the number of characters transmitted, while pmflush returns a value of zero on successful completion.

for either routine, a negative value is returned if an error was encountered β€” and bestie you can pass that straight to pmErrStr(3) to obtain the associated error message. handy fr fr. 🌈


πŸŽ€ FILES πŸŽ€

pmprintf uses the mkstemp(3) function to create a temporary file. that temporary file is deleted when pmflush is called. so clean, so tidy, we love a routine that cleans up after itself. ✨


🌈 ENVIRONMENT 🌈

the environment variable PCP_STDERR controls the output technique used by pmflush:

  • if PCP_STDERR is unset, the text is written onto the stderr stream of the caller.
  • if PCP_STDERR is set to the literal reserved word DISPLAY, then the text will be displayed as a GUI dialog using xconfirm(1). ooooh fancy πŸ¦‹
  • if PCP_STDERR is set to any other value, then pmflush interprets the value as a file name and appends the text to that file. the file is created if it doesn't already exist, and in this case if the file creation fails, then stderr is used instead. (that parenthetical energy, but make it a real fallback 😭)

πŸ‘‘ SEE ALSO πŸ‘‘

pmdbg(1), fprintf(3), mkstemp(3), pmErrStr(3) and PMAPI(3).


and that's the whole page, bestie!! πŸ’– this came to you straight from the Performance Co-Pilot corner of the universe, PCP edition, filed under PMPRINTF(3). go forth and format responsibly. mwah πŸ«ΆπŸŽ€πŸŒΈ

πŸ“¦ where this page comes from