1explain_dup2_or_die(3) Library Functions Manual explain_dup2_or_die(3)
2
3
4
6 explain_dup2_or_die - duplicate a file descriptor and report errors
7
9 #include <libexplain/dup2.h>
10 void explain_dup2_or_die(int oldfd, int newfd);
11
13 The explain_dup2_or_die function is used to call the dup2(2) system
14 call. On failure an explanation will be printed to stderr, obtained
15 from explain_dup2(3), and then the process terminates by calling
16 exit(EXIT_FAILURE).
17
18 This function is intended to be used in a fashion similar to the fol‐
19 lowing example:
20 explain_dup2_or_die(oldfd, newfd);
21
22 oldfd The oldfd, exactly as to be passed to the dup2(2) system call.
23
24 newfd The newfd, exactly as to be passed to the dup2(2) system call.
25
26 Returns:
27 This function only returns on success. On failure, prints an
28 explanation and exits.
29
31 dup2(2) duplicate a file descriptor
32
33 explain_dup2(3)
34 explain dup2(2) errors
35
36 exit(2) terminate the calling process
37
39 libexplain version 1.4
40 Copyright (C) 2008 Peter Miller
41
42
43
44 explain_dup2_or_die(3)