chiark / gitweb /
Remove support for auto-spawning VTs
[elogind.git] / man / sd_is_fifo.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   This file is part of elogind.
7
8   Copyright 2010 Lennart Poettering
9
10   elogind is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   elogind is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with elogind; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="sd_is_fifo"
25   xmlns:xi="http://www.w3.org/2001/XInclude">
26
27   <refentryinfo>
28     <title>sd_is_fifo</title>
29     <productname>elogind</productname>
30
31     <authorgroup>
32       <author>
33         <contrib>Developer</contrib>
34         <firstname>Lennart</firstname>
35         <surname>Poettering</surname>
36         <email>lennart@poettering.net</email>
37       </author>
38     </authorgroup>
39   </refentryinfo>
40
41   <refmeta>
42     <refentrytitle>sd_is_fifo</refentrytitle>
43     <manvolnum>3</manvolnum>
44   </refmeta>
45
46   <refnamediv>
47     <refname>sd_is_fifo</refname>
48     <refname>sd_is_socket</refname>
49     <refname>sd_is_socket_inet</refname>
50     <refname>sd_is_socket_unix</refname>
51     <refname>sd_is_special</refname>
52     <refpurpose>Check the type of a file descriptor</refpurpose>
53   </refnamediv>
54
55   <refsynopsisdiv>
56     <funcsynopsis>
57       <funcsynopsisinfo>#include &lt;elogind/sd-daemon.h&gt;</funcsynopsisinfo>
58
59       <funcprototype>
60         <funcdef>int <function>sd_is_fifo</function></funcdef>
61         <paramdef>int <parameter>fd</parameter></paramdef>
62         <paramdef>const char *<parameter>path</parameter></paramdef>
63       </funcprototype>
64
65       <funcprototype>
66         <funcdef>int <function>sd_is_socket</function></funcdef>
67         <paramdef>int <parameter>fd</parameter></paramdef>
68         <paramdef>int <parameter>family</parameter></paramdef>
69         <paramdef>int <parameter>type</parameter></paramdef>
70         <paramdef>int <parameter>listening</parameter></paramdef>
71       </funcprototype>
72
73       <funcprototype>
74         <funcdef>int <function>sd_is_socket_inet</function></funcdef>
75         <paramdef>int <parameter>fd</parameter></paramdef>
76         <paramdef>int <parameter>family</parameter></paramdef>
77         <paramdef>int <parameter>type</parameter></paramdef>
78         <paramdef>int <parameter>listening</parameter></paramdef>
79         <paramdef>uint16_t <parameter>port</parameter></paramdef>
80       </funcprototype>
81
82       <funcprototype>
83         <funcdef>int <function>sd_is_socket_unix</function></funcdef>
84         <paramdef>int <parameter>fd</parameter></paramdef>
85         <paramdef>int <parameter>type</parameter></paramdef>
86         <paramdef>int <parameter>listening</parameter></paramdef>
87         <paramdef>const char *<parameter>path</parameter></paramdef>
88         <paramdef>size_t <parameter>length</parameter></paramdef>
89       </funcprototype>
90
91       <funcprototype>
92         <funcdef>int <function>sd_is_special</function></funcdef>
93         <paramdef>int <parameter>fd</parameter></paramdef>
94         <paramdef>const char *<parameter>path</parameter></paramdef>
95       </funcprototype>
96
97     </funcsynopsis>
98   </refsynopsisdiv>
99
100   <refsect1>
101     <title>Description</title>
102
103     <para><function>sd_is_fifo()</function> may be called to check
104     whether the specified file descriptor refers to a FIFO or pipe. If
105     the <parameter>path</parameter> parameter is not
106     <constant>NULL</constant>, it is checked whether the FIFO is bound
107     to the specified file system path.</para>
108
109     <para><function>sd_is_socket()</function> may be called to check
110     whether the specified file descriptor refers to a socket. If the
111     <parameter>family</parameter> parameter is not
112     <constant>AF_UNSPEC</constant>, it is checked whether the socket
113     is of the specified family (AF_UNIX, <constant>AF_INET</constant>,
114     ...). If the <parameter>type</parameter> parameter is not 0, it is
115     checked whether the socket is of the specified type
116     (<constant>SOCK_STREAM</constant>,
117     <constant>SOCK_DGRAM</constant>, ...). If the
118     <parameter>listening</parameter> parameter is positive, it is
119     checked whether the socket is in accepting mode, i.e.
120     <function>listen()</function> has been called for it. If
121     <parameter>listening</parameter> is 0, it is checked whether the
122     socket is not in this mode. If the parameter is negative, no such
123     check is made. The <parameter>listening</parameter> parameter
124     should only be used for stream sockets and should be set to a
125     negative value otherwise.</para>
126
127     <para><function>sd_is_socket_inet()</function> is similar to
128     <function>sd_is_socket()</function>, but optionally checks the
129     IPv4 or IPv6 port number the socket is bound to, unless
130     <parameter>port</parameter> is zero. For this call
131     <parameter>family</parameter> must be passed as either
132     <constant>AF_UNSPEC</constant>, <constant>AF_INET</constant>, or
133     <constant>AF_INET6</constant>.</para>
134
135     <para><function>sd_is_socket_unix()</function> is similar to
136     <function>sd_is_socket()</function> but optionally checks the
137     <constant>AF_UNIX</constant> path the socket is bound to, unless
138     the <parameter>path</parameter> parameter is
139     <constant>NULL</constant>. For normal file system
140     <constant>AF_UNIX</constant> sockets, set the
141     <parameter>length</parameter> parameter to 0. For Linux abstract
142     namespace sockets, set the <parameter>length</parameter> to the
143     size of the address, including the initial 0 byte, and set the
144     <parameter>path</parameter> to the initial 0 byte of the socket
145     address.</para>
146
147     <para><function>sd_is_special()</function> may be called to check
148     whether the specified file descriptor refers to a special file. If
149     the <parameter>path</parameter> parameter is not
150     <constant>NULL</constant>, it is checked whether the file
151     descriptor is bound to the specified file name. Special files in
152     this context are character device nodes and files in
153     <filename>/proc</filename> or <filename>/sys</filename>.</para>
154   </refsect1>
155
156   <refsect1>
157     <title>Return Value</title>
158
159     <para>On failure, these calls return a negative errno-style error
160     code. If the file descriptor is of the specified type and bound to
161     the specified address, a positive return value is returned,
162     otherwise zero.</para>
163   </refsect1>
164
165   <refsect1>
166     <title>Notes</title>
167
168     <xi:include href="libelogind-pkgconfig.xml" xpointer="pkgconfig-text"/>
169
170     <para>Internally, these function use a combination of
171     <filename>fstat()</filename> and
172     <filename>getsockname()</filename> to check the file descriptor
173     type and where it is bound to.</para>
174   </refsect1>
175
176   <refsect1>
177     <title>See Also</title>
178     <para>
179       <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
180       <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
181       <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
182       <citerefentry><refentrytitle>logind.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
183       <citerefentry><refentrytitle>elogind.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>
184     </para>
185   </refsect1>
186
187 </refentry>