1explain_fork(3) Library Functions Manual explain_fork(3)
2
3
4
6 explain_fork - explain fork(2) errors
7
9 #include <libexplain/fork.h>
10 const char *explain_fork(void);
11 const char *explain_errno_fork(int errnum);
12 void explain_message_fork(char *message, int message_size);
13 void explain_message_errno_fork(char *message, int message_size, int
14 errnum);
15
17 These functions may be used to obtain explanations for errors returned
18 by the fork(2) system call.
19
20 explain_fork
21 const char *explain_fork(void);
22
23 The explain_fork function is used to obtain an explanation of an error
24 returned by the fork(2) system call. The least the message will con‐
25 tain is the value of strerror(errno), but usually it will do much bet‐
26 ter, and indicate the underlying cause in more detail.
27
28 The errno global variable will be used to obtain the error value to be
29 decoded.
30
31 This function is intended to be used in a fashion similar to the fol‐
32 lowing example:
33 if (fork() < 0)
34 {
35 fprintf(stderr, "%s\n", explain_fork());
36 exit(EXIT_FAILURE);
37 }
38
39 Returns:
40 The message explaining the error. This message buffer is
41 shared by all libexplain functions which do not supply a buffer
42 in their argument list. This will be overwritten by the next
43 call to any libexplain function which shares this buffer,
44 including other threads.
45
46 Note: This function is not thread safe, because it shares a return buf‐
47 fer across all threads, and many other functions in this library.
48
49 explain_errno_fork
50 const char *explain_errno_fork(int errnum);
51
52 The explain_errno_fork function is used to obtain an explanation of an
53 error returned by the fork(2) system call. The least the message will
54 contain is the value of strerror(errnum), but usually it will do much
55 better, and indicate the underlying cause in more detail.
56
57 This function is intended to be used in a fashion similar to the fol‐
58 lowing example:
59 if (fork() < 0)
60 {
61 int err = errno;
62 fprintf(stderr, "%s\n", explain_errno_fork(err, ));
63 exit(EXIT_FAILURE);
64 }
65
66 errnum The error value to be decoded, usually obtained from the errno
67 global variable just before this function is called. This is
68 necessary if you need to call any code between the system call
69 to be explained and this function, because many libc functions
70 will alter the value of errno.
71
72 Returns:
73 The message explaining the error. This message buffer is
74 shared by all libexplain functions which do not supply a buffer
75 in their argument list. This will be overwritten by the next
76 call to any libexplain function which shares this buffer,
77 including other threads.
78
79 Note: This function is not thread safe, because it shares a return buf‐
80 fer across all threads, and many other functions in this library.
81
82 explain_message_fork
83 void explain_message_fork(char *message, int message_size);
84
85 The explain_message_fork function may be used to obtain an explanation
86 of an error returned by the fork(2) system call. The least the message
87 will contain is the value of strerror(errno), but usually it will do
88 much better, and indicate the underlying cause in more detail.
89
90 The errno global variable will be used to obtain the error value to be
91 decoded.
92
93 This function is intended to be used in a fashion similar to the fol‐
94 lowing example:
95 if (fork() < 0)
96 {
97 char message[3000];
98 explain_message_fork(message, sizeof(message), );
99 fprintf(stderr, "%s\n", message);
100 exit(EXIT_FAILURE);
101 }
102
103 message The location in which to store the returned message. If a
104 suitable message return buffer is supplied, this function is
105 thread safe.
106
107 message_size
108 The size in bytes of the location in which to store the
109 returned message.
110
111 explain_message_errno_fork
112 void explain_message_errno_fork(char *message, int message_size, int
113 errnum);
114
115 The explain_message_errno_fork function may be used to obtain an expla‐
116 nation of an error returned by the fork(2) system call. The least the
117 message will contain is the value of strerror(errnum), but usually it
118 will do much better, and indicate the underlying cause in more detail.
119
120 This function is intended to be used in a fashion similar to the fol‐
121 lowing example:
122 if (fork() < 0)
123 {
124 int err = errno;
125 char message[3000];
126 explain_message_errno_fork(message, sizeof(message), err, );
127 fprintf(stderr, "%s\n", message);
128 exit(EXIT_FAILURE);
129 }
130
131 message The location in which to store the returned message. If a
132 suitable message return buffer is supplied, this function is
133 thread safe.
134
135 message_size
136 The size in bytes of the location in which to store the
137 returned message.
138
139 errnum The error value to be decoded, usually obtained from the errno
140 global variable just before this function is called. This is
141 necessary if you need to call any code between the system call
142 to be explained and this function, because many libc functions
143 will alter the value of errno.
144
146 fork(2) create a child process
147
148 explain_fork_or_die(3)
149 create a child process and report errors
150
152 libexplain version 1.4
153 Copyright (C) 2008 Peter Miller
154
155
156
157 explain_fork(3)