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

# libmaketmpfilefd(3)

create a temporary named file

## NAME

pm\_make\_tmpfile\_fd() - create a temporary named file

## SYNOPSIS

```
#include <netpbm/pm.h>
pm_make_tmpfile(int *         fdP,
                const char ** filenameP);
```

## EXAMPLE

This simple example creates a temporary file, writes "hello world" to it, then writes some search patterns to it, then uses it as input to **grep**:

```
#include <netpbm/pm.h>
int fd;
const char * myfilename;
pm_make_tmpfile_fd(&fdP, &myfilename);
write(fd, "^account:\\s.*\n", 16);
fprintf(fd, "^name:\\s.*\n", 13);
close(fd);
asprintfN(&grepCommand, "grep --file='%s' /tmp/infile >/tmp/outfile");
system(grepCommand);
strfree(grepCommand);
unlink(myfilename);
strfree(myfilename);
```

## DESCRIPTION

This library function is part of **Netpbm**(1) .

**pm\_make\_tmpfile\_fd()** is analogous to **pm\_make\_tmpfile()**(1) .  The only difference is that it opens the file as a low level file, as **open()** would, rather than as a stream, as **fopen()** would.

If you don't need to access the file by name, use **pm\_tmpfile\_fd()** instead, because it's cleaner.  With **pm\_tmpfile\_fd()**, the operating system always deletes the temporary file when your program exits, if the program failed to clean up after itself.

## HISTORY

**pm\_tmpfile()** was introduced in Netpbm 10.42 (March 2008).

## DOCUMENT SOURCE

This manual page was generated by the Netpbm tool 'makeman' from HTML source.  The master documentation is at

-

  **http://netpbm.sourceforge.net/doc/libmaketmpfilefd.html**
