1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>GUnixFDList: GIO Reference Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="index.html" title="GIO Reference Manual">
8 <link rel="up" href="networking.html" title="Low-level network support">
9 <link rel="prev" href="GSocketControlMessage.html" title="GSocketControlMessage">
10 <link rel="next" href="GUnixFDMessage.html" title="GUnixFDMessage">
11 <meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
16 <td width="100%" align="left" class="shortcuts">
17 <a href="#" class="shortcut">Top</a><span id="nav_description"> <span class="dim">|</span>
18 <a href="#GUnixFDList.description" class="shortcut">Description</a></span><span id="nav_hierarchy"> <span class="dim">|</span>
19 <a href="#GUnixFDList.object-hierarchy" class="shortcut">Object Hierarchy</a></span>
21 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
22 <td><a accesskey="u" href="networking.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
23 <td><a accesskey="p" href="GSocketControlMessage.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
24 <td><a accesskey="n" href="GUnixFDMessage.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
26 <div class="refentry">
27 <a name="GUnixFDList"></a><div class="titlepage"></div>
28 <div class="refnamediv"><table width="100%"><tr>
30 <h2><span class="refentrytitle"><a name="GUnixFDList.top_of_page"></a>GUnixFDList</span></h2>
31 <p>GUnixFDList — An object containing a set of UNIX file descriptors</p>
33 <td class="gallery_image" valign="top" align="right"></td>
35 <div class="refsect1">
36 <a name="GUnixFDList.functions"></a><h2>Functions</h2>
37 <div class="informaltable"><table class="informaltable" width="100%" border="0">
39 <col width="150px" class="functions_return">
40 <col class="functions_name">
44 <td class="function_type">
45 <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="returnvalue">GUnixFDList</span></a> *
47 <td class="function_name">
48 <a class="link" href="GUnixFDList.html#g-unix-fd-list-new-from-array" title="g_unix_fd_list_new_from_array ()">g_unix_fd_list_new_from_array</a> <span class="c_punctuation">()</span>
52 <td class="function_type">
53 <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="returnvalue">GUnixFDList</span></a> *
55 <td class="function_name">
56 <a class="link" href="GUnixFDList.html#g-unix-fd-list-new" title="g_unix_fd_list_new ()">g_unix_fd_list_new</a> <span class="c_punctuation">()</span>
60 <td class="function_type">
61 <a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a>
63 <td class="function_name">
64 <a class="link" href="GUnixFDList.html#g-unix-fd-list-get-length" title="g_unix_fd_list_get_length ()">g_unix_fd_list_get_length</a> <span class="c_punctuation">()</span>
68 <td class="function_type">
69 <a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a>
71 <td class="function_name">
72 <a class="link" href="GUnixFDList.html#g-unix-fd-list-get" title="g_unix_fd_list_get ()">g_unix_fd_list_get</a> <span class="c_punctuation">()</span>
76 <td class="function_type">const <a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> *
78 <td class="function_name">
79 <a class="link" href="GUnixFDList.html#g-unix-fd-list-peek-fds" title="g_unix_fd_list_peek_fds ()">g_unix_fd_list_peek_fds</a> <span class="c_punctuation">()</span>
83 <td class="function_type">
84 <a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> *
86 <td class="function_name">
87 <a class="link" href="GUnixFDList.html#g-unix-fd-list-steal-fds" title="g_unix_fd_list_steal_fds ()">g_unix_fd_list_steal_fds</a> <span class="c_punctuation">()</span>
91 <td class="function_type">
92 <a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a>
94 <td class="function_name">
95 <a class="link" href="GUnixFDList.html#g-unix-fd-list-append" title="g_unix_fd_list_append ()">g_unix_fd_list_append</a> <span class="c_punctuation">()</span>
101 <div class="refsect1">
102 <a name="GUnixFDList.other"></a><h2>Types and Values</h2>
103 <div class="informaltable"><table class="informaltable" width="100%" border="0">
105 <col width="150px" class="name">
106 <col class="description">
109 <td class="datatype_keyword"> </td>
110 <td class="function_name"><a class="link" href="GUnixFDList.html#GUnixFDList-struct" title="GUnixFDList">GUnixFDList</a></td>
114 <div class="refsect1">
115 <a name="GUnixFDList.object-hierarchy"></a><h2>Object Hierarchy</h2>
116 <pre class="screen"> <a href="../gobject-The-Base-Object-Type.html#GObject-struct">GObject</a>
117 <span class="lineart">╰──</span> GUnixFDList
120 <div class="refsect1">
121 <a name="GUnixFDList.includes"></a><h2>Includes</h2>
122 <pre class="synopsis">#include <gio/gunixfdlist.h>
125 <div class="refsect1">
126 <a name="GUnixFDList.description"></a><h2>Description</h2>
127 <p>A <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a> contains a list of file descriptors. It owns the file
128 descriptors that it contains, closing them when finalized.</p>
129 <p>It may be wrapped in a <a class="link" href="GUnixFDMessage.html" title="GUnixFDMessage"><span class="type">GUnixFDMessage</span></a> and sent over a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> in
130 the <code class="literal">G_SOCKET_ADDRESS_UNIX</code> family by using <a class="link" href="GSocket.html#g-socket-send-message" title="g_socket_send_message ()"><code class="function">g_socket_send_message()</code></a>
131 and received using <a class="link" href="GSocket.html#g-socket-receive-message" title="g_socket_receive_message ()"><code class="function">g_socket_receive_message()</code></a>.</p>
132 <p>Note that <code class="literal"><gio/gunixfdlist.h></code> belongs to the UNIX-specific GIO
133 interfaces, thus you have to use the <code class="literal">gio-unix-2.0.pc</code> pkg-config
134 file when using it.</p>
136 <div class="refsect1">
137 <a name="GUnixFDList.functions_details"></a><h2>Functions</h2>
138 <div class="refsect2">
139 <a name="g-unix-fd-list-new-from-array"></a><h3>g_unix_fd_list_new_from_array ()</h3>
140 <pre class="programlisting"><a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="returnvalue">GUnixFDList</span></a> *
141 g_unix_fd_list_new_from_array (<em class="parameter"><code>const <a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> *fds</code></em>,
142 <em class="parameter"><code><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> n_fds</code></em>);</pre>
143 <p>Creates a new <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a> containing the file descriptors given in
144 <em class="parameter"><code>fds</code></em>
145 . The file descriptors become the property of the new list and
146 may no longer be used by the caller. The array itself is owned by
148 <p>Each file descriptor in the array should be set to close-on-exec.</p>
149 <p>If <em class="parameter"><code>n_fds</code></em>
150 is -1 then <em class="parameter"><code>fds</code></em>
151 must be terminated with -1.</p>
152 <div class="refsect3">
153 <a name="g-unix-fd-list-new-from-array.parameters"></a><h4>Parameters</h4>
154 <div class="informaltable"><table class="informaltable" width="100%" border="0">
156 <col width="150px" class="parameters_name">
157 <col class="parameters_description">
158 <col width="200px" class="parameters_annotations">
162 <td class="parameter_name"><p>fds</p></td>
163 <td class="parameter_description"><p> the initial list of file descriptors. </p></td>
164 <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=n_fds]</span></td>
167 <td class="parameter_name"><p>n_fds</p></td>
168 <td class="parameter_description"><p>the length of <span class="type">fds</span>, or -1</p></td>
169 <td class="parameter_annotations"> </td>
174 <div class="refsect3">
175 <a name="g-unix-fd-list-new-from-array.returns"></a><h4>Returns</h4>
176 <p> a new <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a></p>
178 <p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
181 <div class="refsect2">
182 <a name="g-unix-fd-list-new"></a><h3>g_unix_fd_list_new ()</h3>
183 <pre class="programlisting"><a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="returnvalue">GUnixFDList</span></a> *
184 g_unix_fd_list_new (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
185 <p>Creates a new <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a> containing no file descriptors.</p>
186 <div class="refsect3">
187 <a name="g-unix-fd-list-new.returns"></a><h4>Returns</h4>
188 <p> a new <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a></p>
190 <p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
193 <div class="refsect2">
194 <a name="g-unix-fd-list-get-length"></a><h3>g_unix_fd_list_get_length ()</h3>
195 <pre class="programlisting"><a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a>
196 g_unix_fd_list_get_length (<em class="parameter"><code><a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a> *list</code></em>);</pre>
197 <p>Gets the length of <em class="parameter"><code>list</code></em>
198 (ie: the number of file descriptors
199 contained within).</p>
200 <div class="refsect3">
201 <a name="g-unix-fd-list-get-length.parameters"></a><h4>Parameters</h4>
202 <div class="informaltable"><table class="informaltable" width="100%" border="0">
204 <col width="150px" class="parameters_name">
205 <col class="parameters_description">
206 <col width="200px" class="parameters_annotations">
209 <td class="parameter_name"><p>list</p></td>
210 <td class="parameter_description"><p>a <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a></p></td>
211 <td class="parameter_annotations"> </td>
215 <div class="refsect3">
216 <a name="g-unix-fd-list-get-length.returns"></a><h4>Returns</h4>
217 <p> the length of <em class="parameter"><code>list</code></em>
220 <p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
223 <div class="refsect2">
224 <a name="g-unix-fd-list-get"></a><h3>g_unix_fd_list_get ()</h3>
225 <pre class="programlisting"><a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a>
226 g_unix_fd_list_get (<em class="parameter"><code><a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a> *list</code></em>,
227 <em class="parameter"><code><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> index_</code></em>,
228 <em class="parameter"><code><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
229 <p>Gets a file descriptor out of <em class="parameter"><code>list</code></em>
231 <p><em class="parameter"><code>index_</code></em>
232 specifies the index of the file descriptor to get. It is a
233 programmer error for <em class="parameter"><code>index_</code></em>
234 to be out of range; see
235 <a class="link" href="GUnixFDList.html#g-unix-fd-list-get-length" title="g_unix_fd_list_get_length ()"><code class="function">g_unix_fd_list_get_length()</code></a>.</p>
236 <p>The file descriptor is duplicated using <code class="function">dup()</code> and set as
237 close-on-exec before being returned. You must call <code class="function">close()</code> on it
238 when you are done.</p>
239 <p>A possible cause of failure is exceeding the per-process or
240 system-wide file descriptor limit.</p>
241 <div class="refsect3">
242 <a name="g-unix-fd-list-get.parameters"></a><h4>Parameters</h4>
243 <div class="informaltable"><table class="informaltable" width="100%" border="0">
245 <col width="150px" class="parameters_name">
246 <col class="parameters_description">
247 <col width="200px" class="parameters_annotations">
251 <td class="parameter_name"><p>list</p></td>
252 <td class="parameter_description"><p>a <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a></p></td>
253 <td class="parameter_annotations"> </td>
256 <td class="parameter_name"><p>index_</p></td>
257 <td class="parameter_description"><p>the index into the list</p></td>
258 <td class="parameter_annotations"> </td>
261 <td class="parameter_name"><p>error</p></td>
262 <td class="parameter_description"><p>a <a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> pointer</p></td>
263 <td class="parameter_annotations"> </td>
268 <div class="refsect3">
269 <a name="g-unix-fd-list-get.returns"></a><h4>Returns</h4>
270 <p> the file descriptor, or -1 in case of error</p>
272 <p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
275 <div class="refsect2">
276 <a name="g-unix-fd-list-peek-fds"></a><h3>g_unix_fd_list_peek_fds ()</h3>
277 <pre class="programlisting">const <a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> *
278 g_unix_fd_list_peek_fds (<em class="parameter"><code><a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a> *list</code></em>,
279 <em class="parameter"><code><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> *length</code></em>);</pre>
280 <p>Returns the array of file descriptors that is contained in this
282 <p>After this call, the descriptors remain the property of <em class="parameter"><code>list</code></em>
284 caller must not close them and must not free the array. The array is
285 valid only until <em class="parameter"><code>list</code></em>
286 is changed in any way.</p>
287 <p>If <em class="parameter"><code>length</code></em>
288 is non-<a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then it is set to the number of file
289 descriptors in the returned array. The returned array is also
290 terminated with -1.</p>
291 <p>This function never returns <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. In case there are no file
292 descriptors contained in <em class="parameter"><code>list</code></em>
293 , an empty array is returned.</p>
294 <div class="refsect3">
295 <a name="g-unix-fd-list-peek-fds.parameters"></a><h4>Parameters</h4>
296 <div class="informaltable"><table class="informaltable" width="100%" border="0">
298 <col width="150px" class="parameters_name">
299 <col class="parameters_description">
300 <col width="200px" class="parameters_annotations">
304 <td class="parameter_name"><p>list</p></td>
305 <td class="parameter_description"><p>a <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a></p></td>
306 <td class="parameter_annotations"> </td>
309 <td class="parameter_name"><p>length</p></td>
310 <td class="parameter_description"><p> pointer to the length of the returned
311 array, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td>
312 <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>][<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
317 <div class="refsect3">
318 <a name="g-unix-fd-list-peek-fds.returns"></a><h4>Returns</h4>
321 <p><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=length][<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
323 <p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
326 <div class="refsect2">
327 <a name="g-unix-fd-list-steal-fds"></a><h3>g_unix_fd_list_steal_fds ()</h3>
328 <pre class="programlisting"><a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> *
329 g_unix_fd_list_steal_fds (<em class="parameter"><code><a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a> *list</code></em>,
330 <em class="parameter"><code><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> *length</code></em>);</pre>
331 <p>Returns the array of file descriptors that is contained in this
333 <p>After this call, the descriptors are no longer contained in
334 <em class="parameter"><code>list</code></em>
335 . Further calls will return an empty list (unless more
336 descriptors have been added).</p>
337 <p>The return result of this function must be freed with <a href="../glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>.
338 The caller is also responsible for closing all of the file
339 descriptors. The file descriptors in the array are set to
341 <p>If <em class="parameter"><code>length</code></em>
342 is non-<a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then it is set to the number of file
343 descriptors in the returned array. The returned array is also
344 terminated with -1.</p>
345 <p>This function never returns <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. In case there are no file
346 descriptors contained in <em class="parameter"><code>list</code></em>
347 , an empty array is returned.</p>
348 <div class="refsect3">
349 <a name="g-unix-fd-list-steal-fds.parameters"></a><h4>Parameters</h4>
350 <div class="informaltable"><table class="informaltable" width="100%" border="0">
352 <col width="150px" class="parameters_name">
353 <col class="parameters_description">
354 <col width="200px" class="parameters_annotations">
358 <td class="parameter_name"><p>list</p></td>
359 <td class="parameter_description"><p>a <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a></p></td>
360 <td class="parameter_annotations"> </td>
363 <td class="parameter_name"><p>length</p></td>
364 <td class="parameter_description"><p> pointer to the length of the returned
365 array, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td>
366 <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>][<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
371 <div class="refsect3">
372 <a name="g-unix-fd-list-steal-fds.returns"></a><h4>Returns</h4>
375 <p><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=length][<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
377 <p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
380 <div class="refsect2">
381 <a name="g-unix-fd-list-append"></a><h3>g_unix_fd_list_append ()</h3>
382 <pre class="programlisting"><a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a>
383 g_unix_fd_list_append (<em class="parameter"><code><a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a> *list</code></em>,
384 <em class="parameter"><code><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> fd</code></em>,
385 <em class="parameter"><code><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
386 <p>Adds a file descriptor to <em class="parameter"><code>list</code></em>
388 <p>The file descriptor is duplicated using <code class="function">dup()</code>. You keep your copy
389 of the descriptor and the copy contained in <em class="parameter"><code>list</code></em>
391 when <em class="parameter"><code>list</code></em>
393 <p>A possible cause of failure is exceeding the per-process or
394 system-wide file descriptor limit.</p>
395 <p>The index of the file descriptor in the list is returned. If you use
396 this index with <a class="link" href="GUnixFDList.html#g-unix-fd-list-get" title="g_unix_fd_list_get ()"><code class="function">g_unix_fd_list_get()</code></a> then you will receive back a
397 duplicated copy of the same file descriptor.</p>
398 <div class="refsect3">
399 <a name="g-unix-fd-list-append.parameters"></a><h4>Parameters</h4>
400 <div class="informaltable"><table class="informaltable" width="100%" border="0">
402 <col width="150px" class="parameters_name">
403 <col class="parameters_description">
404 <col width="200px" class="parameters_annotations">
408 <td class="parameter_name"><p>list</p></td>
409 <td class="parameter_description"><p>a <a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a></p></td>
410 <td class="parameter_annotations"> </td>
413 <td class="parameter_name"><p>fd</p></td>
414 <td class="parameter_description"><p>a valid open file descriptor</p></td>
415 <td class="parameter_annotations"> </td>
418 <td class="parameter_name"><p>error</p></td>
419 <td class="parameter_description"><p>a <a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> pointer</p></td>
420 <td class="parameter_annotations"> </td>
425 <div class="refsect3">
426 <a name="g-unix-fd-list-append.returns"></a><h4>Returns</h4>
427 <p> the index of the appended fd in case of success, else -1
428 (and <em class="parameter"><code>error</code></em>
431 <p class="since">Since: <a class="link" href="api-index-2-24.html#api-index-2.24">2.24</a></p>
434 <div class="refsect1">
435 <a name="GUnixFDList.other_details"></a><h2>Types and Values</h2>
436 <div class="refsect2">
437 <a name="GUnixFDList-struct"></a><h3>GUnixFDList</h3>
438 <pre class="programlisting">typedef struct _GUnixFDList GUnixFDList;</pre>
439 <p><a class="link" href="GUnixFDList.html" title="GUnixFDList"><span class="type">GUnixFDList</span></a> is an opaque data structure and can only be accessed
440 using the following functions.</p>
443 <div class="refsect1">
444 <a name="GUnixFDList.see-also"></a><h2>See Also</h2>
445 <p><a class="link" href="GUnixFDMessage.html" title="GUnixFDMessage"><span class="type">GUnixFDMessage</span></a></p>
449 <hr>Generated by GTK-Doc V1.25.1</div>