---
name: "explain_open_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_open_or_die"
---

# explain\_open\_or\_die(3)

open file and report errors

## NAME

explain\_open\_or\_die - open file and report errors

## SYNOPSIS

\#include \<fcntl.h\>\
 \#include \<libexplain/open.h\>

int explain\_open\_or\_die(const char \*pathname, int flags, int mode);

## DESCRIPTION

Given a pathname for a file, open() returns a file descriptor, a small, non‐negative integer for use in subsequent system calls ([read(2)](/read/2.md), [write(2)](/write/2.md), [lseek(2)](/lseek/2.md), [fcntl(2)](/fcntl/2.md), etc.).  The file descriptor returned by a successful call will be the lowest‐numbered file descriptor not currently open for the process. See [*open*(2)](/open/2.md) for more information.

## RETURN VALUE

On success, the new file descriptor is returned.

On error, a description of the error is obtained via [*explain\_open*(3)](/explain_open/3.md), and printed on *stderr*.  The process is the terminated via a call to the `exit(EXIT_FAILURE)` function.

## COPYRIGHT

libexplain version 1.4\
 Copyright (C) 2008 Peter Miller

## AUTHOR

Written by Peter Miller \<pmiller@opensource.org.au\>
