---
name: "explain_pclose_or_die"
section: "3"
platform: "linux"
package: "libexplain-dev"
version: "1.4.D001-16"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/explain_pclose_or_die"
---

# explain\_pclose\_or\_die(3)

process I/O and report errors

## NAME

explain\_pclose\_or\_die - process I/O and report errors

## SYNOPSIS

\#include \<libexplain/pclose.h\>

int explain\_pclose\_or\_die(FILE \*fp);\
 int explain\_pclose\_success(FILE \*fp);\
 void explain\_pclose\_success\_or\_die(FILE \*fp);

## DESCRIPTION

These functions may be used to wait for program termination, and then reprt errors returned by the [*pclose*(3)](/pclose/3.md) system call.

### explain\_pclose\_or\_die

int explain\_pclose\_or\_die(FILE \*fp);

The **explain\_pclose\_or\_die** function is used to call the [*pclose*(3)](/pclose/3.md) system call.  On failure an explanation will be printed to *stderr*, obtained from [*explain\_pclose*(3)](/explain_pclose/3.md), and then the process terminates by calling `exit(EXIT_FAILURE)`.

This function is intended to be used in a fashion similar to the following example:

```
int status = explain_pclose_or_die(fp);
```

- *fp*

  The fp, exactly as to be passed to the [*pclose*(3)](/pclose/3.md) system call.

- Returns:

  This function only returns on success, see [*pclose*(3)](/pclose/3.md) for more information.  On failure, prints an explanation and exits.

### explain\_pclose\_success\_or\_die

void explain\_pclose\_success\_or\_die(FILE \*);

The **explain\_pclose\_success\_or\_die** function is used to call the [*pclose*(3)](/pclose/3.md) system call.  On failure, including any exit status other than EXIT\_SUCCESS, an explanation will be printed to *stderr*, obtained from [*explain\_pclose*(3)](/explain_pclose/3.md), and then the process terminates by calling `exit(EXIT_FAILURE)`.

This function is intended to be used in a fashion similar to the following example:

```
explain_pclose_success_or_die(fp);
```

- *fp*

  The fp, exactly as to be passed to the [*pclose*(3)](/pclose/3.md) system call.

- Returns:

  This function only returns on success. On failure, prints an explanation and exits.

### explain\_pclose\_success

int explain\_pclose\_success(FILE \*fp);

The **explain\_pclose\_success** function is used to call the [*pclose*(3)](/pclose/3.md) system call.  On failure, including any exit status other than EXIT\_SUCCESS, an explanation will be printed to *stderr*, obtained from [*explain\_pclose*(3)](/explain_pclose/3.md). However, the priniting of an error message does **not** also cause [*exit*(2)](/exit/2.md) to be called.

This function is intended to be used in a fashion similar to the following example:

```
int status = explain_pclose_success(command);
```

- *fp*

  The fp, exactly as to be passed to the [*pclose*(3)](/pclose/3.md) system call.

- Returns:

  the value returned by the [*pclose*(3)](/pclose/3.md) system call. In all cases other than EXIT\_SUCCESS, an error message will also have been printed to stderr.

## SEE ALSO

- [*pclose*(3)](/pclose/3.md)

  process I/O

- [*explain\_pclose*(3)](/explain_pclose/3.md)

  explain [*pclose*(3)](/pclose/3.md) errors

- [*exit*(2)](/exit/2.md)

  terminate the calling process

## COPYRIGHT

libexplain version 1.4\
 Copyright (C) 2009 Peter Miller
