1explain_setsid(3)          Library Functions Manual          explain_setsid(3)
2
3
4

NAME

6       explain_setsid - explain setsid(2) errors
7

SYNOPSIS

9       #include <libexplain/setsid.h>
10       const char *explain_setsid(void);
11       const char *explain_errno_setsid(int errnum, void);
12       void explain_message_setsid(char *message, int message_size, void);
13       void explain_message_errno_setsid(char *message, int message_size, int
14       errnum, void);
15

DESCRIPTION

17       These functions may be used to obtain explanations for errors  returned
18       by the setsid(2) system call.
19
20   explain_setsid
21       const char *explain_setsid(void);
22
23       The  explain_setsid  function  is  used  to obtain an explanation of an
24       error returned by the setsid(2) system call. The least the message will
25       contain  is  the  value of strerror(errno), but usually it will do much
26       better, 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       Returns:
32               The message explaining the error. This message buffer is shared
33               by all libexplain functions which do not  supply  a  buffer  in
34               their argument list.  This will be overwritten by the next call
35               to any libexplain function which shares this buffer,  including
36               other threads.
37
38       Note: This function is not thread safe, because it shares a return buf‐
39       fer across all threads, and many other functions in this library.
40
41       Example: This function is intended to be used in a fashion  similar  to
42       the following example:
43              pid_t result = setsid();
44              if (result < 0)
45              {
46                  fprintf(stderr, "%s\n", explain_setsid());
47                  exit(EXIT_FAILURE);
48              }
49
50       The  above  code  example is available pre-packaged as the explain_set‐
51       sid_or_die(3) function.
52
53   explain_errno_setsid
54       const char *explain_errno_setsid(int errnum, void);
55
56       The explain_errno_setsid function is used to obtain an  explanation  of
57       an  error  returned by the setsid(2) system call. The least the message
58       will contain is the value of strerror(errno), but usually  it  will  do
59       much better, and indicate the underlying cause in more detail.
60
61       errnum  The  error value to be decoded, usually obtained from the errno
62               global variable just before this function is  called.  This  is
63               necessary  if you need to call any code between the system call
64               to be explained and this function, because many libc  functions
65               will alter the value of errno.
66
67       Returns:
68               The message explaining the error. This message buffer is shared
69               by all libexplain functions which do not  supply  a  buffer  in
70               their argument list.  This will be overwritten by the next call
71               to any libexplain function which shares this buffer,  including
72               other threads.
73
74       Note: This function is not thread safe, because it shares a return buf‐
75       fer across all threads, and many other functions in this library.
76
77       Example: This function is intended to be used in a fashion  similar  to
78       the following example:
79              pid_t result = setsid();
80              if (result < 0)
81              {
82                  int err = errno;
83                  fprintf(stderr, "%s\n", explain_errno_setsid(err, ));
84                  exit(EXIT_FAILURE);
85              }
86
87       The  above  code  example is available pre-packaged as the explain_set‐
88       sid_or_die(3) function.
89
90   explain_message_setsid
91       void explain_message_setsid(char *message, int message_size, void);
92
93       The explain_message_setsid function is used to obtain an explanation of
94       an  error  returned by the setsid(2) system call. The least the message
95       will contain is the value of strerror(errno), but usually  it  will  do
96       much better, and indicate the underlying cause in more detail.
97
98       The  errno global variable will be used to obtain the error value to be
99       decoded.
100
101       message The location in which to store the returned message. If a suit‐
102               able message return buffer is supplied, this function is thread
103               safe.
104
105       message_size
106               The size in bytes  of  the  location  in  which  to  store  the
107               returned message.
108
109       Example:  This  function is intended to be used in a fashion similar to
110       the following example:
111              pid_t result = setsid();
112              if (result < 0)
113              {
114                  char message[3000];
115                  explain_message_setsid(message, sizeof(message), );
116                  fprintf(stderr, "%s\n", message);
117                  exit(EXIT_FAILURE);
118              }
119
120       The above code example is available pre-packaged  as  the  explain_set‐
121       sid_or_die(3) function.
122
123   explain_message_errno_setsid
124       void explain_message_errno_setsid(char *message, int message_size, int
125       errnum, void);
126
127       The explain_message_errno_setsid function is used to obtain an explana‐
128       tion  of  an error returned by the setsid(2) system call. The least the
129       message will contain is the value of strerror(errno),  but  usually  it
130       will do much better, and indicate the underlying cause in more detail.
131
132       message The location in which to store the returned message. If a suit‐
133               able message return buffer is supplied, this function is thread
134               safe.
135
136       message_size
137               The  size  in  bytes  of  the  location  in  which to store the
138               returned message.
139
140       errnum  The error value to be decoded, usually obtained from the  errno
141               global  variable  just  before this function is called. This is
142               necessary if you need to call any code between the system  call
143               to  be explained and this function, because many libc functions
144               will alter the value of errno.
145
146       Example: This function is intended to be used in a fashion  similar  to
147       the following example:
148              pid_t result = setsid();
149              if (result < 0)
150              {
151                  int err = errno;
152                  char message[3000];
153                  explain_message_errno_setsid(message, sizeof(message), err,
154                  );
155                  fprintf(stderr, "%s\n", message);
156                  exit(EXIT_FAILURE);
157              }
158
159       The above code example is available pre-packaged  as  the  explain_set‐
160       sid_or_die(3) function.
161

SEE ALSO

163       setsid(2)
164               creates a session and sets the process group ID
165
166       explain_setsid_or_die(3)
167               creates  a  session  and  sets  the process group ID and report
168               errors
169
171       libexplain version 1.4
172       Copyright (C) 2011 Peter Miller
173
174
175
176                                                             explain_setsid(3)
Impressum