]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_login_monitor_new.xml
relicense to LGPLv2.1 (with exceptions)
[thirdparty/systemd.git] / man / sd_login_monitor_new.xml
CommitLineData
0b3b020a
LP
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 systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
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
0b3b020a
LP
13 (at your option) any later version.
14
15 systemd 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
5430f7f2 18 Lesser General Public License for more details.
0b3b020a 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
0b3b020a
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22-->
23
24<refentry id="sd_login_monitor_new">
25
26 <refentryinfo>
27 <title>sd_login_monitor_new</title>
28 <productname>systemd</productname>
29
30 <authorgroup>
31 <author>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
36 </author>
37 </authorgroup>
38 </refentryinfo>
39
40 <refmeta>
41 <refentrytitle>sd_login_monitor_new</refentrytitle>
42 <manvolnum>3</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>sd_login_monitor_new</refname>
47 <refname>sd_login_monitor_unref</refname>
48 <refname>sd_login_monitor_flush</refname>
49 <refname>sd_login_monitor_get_fd</refname>
50 <refpurpose>Monitor login sessions, seats and users</refpurpose>
51 </refnamediv>
52
53 <refsynopsisdiv>
54 <funcsynopsis>
55 <funcsynopsisinfo>#include &lt;systemd/sd-login.h&gt;</funcsynopsisinfo>
56
57 <funcprototype>
58 <funcdef>int <function>sd_login_monitor_new</function></funcdef>
59 <paramdef>const char* <parameter>category</parameter></paramdef>
60 <paramdef>sd_login_monitor** <parameter>ret</parameter></paramdef>
61 </funcprototype>
62
63 <funcprototype>
64 <funcdef>sd_login_monitor* <function>sd_login_monitor_unref</function></funcdef>
65 <paramdef>sd_login_monitor* <parameter>m</parameter></paramdef>
66 </funcprototype>
67
68 <funcprototype>
69 <funcdef>int <function>sd_login_monitor_flush</function></funcdef>
70 <paramdef>sd_login_monitor* <parameter>m</parameter></paramdef>
71 </funcprototype>
72
73 <funcprototype>
74 <funcdef>int <function>sd_login_monitor_get_fd</function></funcdef>
75 <paramdef>sd_login_monitor* <parameter>m</parameter></paramdef>
76 </funcprototype>
77
78 </funcsynopsis>
79 </refsynopsisdiv>
80
81 <refsect1>
82 <title>Description</title>
83
84 <para><function>sd_login_monitor_new()</function> may
85 be used to monitor login session, users and seats. Via
86 a monitor object a file descriptor can be integrated
87 into an application defined event loop which is woken
88 up each time a user logs in, logs out or a seat is
89 added or removed, or a session, user, or seat changes
90 state otherwise. The first parameter takes a string
91 which can be either <literal>seat</literal> (to get
92 only notifications about seats being added, removed or
93 changed), <literal>session</literal> (to get only
94 notifications about sessions being created or removed
95 or changed) or <literal>uid</literal> (to get only
96 notifications when a user changes state in respect to
97 logins). If notifications shall be generated in all
98 these conditions, NULL may be passed. Note that in
99 future additional categories may be defined. The
100 second parameter returns a monitor object and needs to
101 be freed with the
102 <function>sd_login_monitor_unref()</function> call
103 after use.</para>
104
105 <para><function>sd_login_monitor_unref()</function>
106 may be used to destroy a monitor object. Note that
107 this will invalidate any file descriptor returned by
108 <function>sd_login_monitor_get_fd()</function>.</para>
109
110 <para><function>sd_login_monitor_flush()</function>
111 may be used to reset the wakeup state of the monitor
112 object. Whenever an event causes the monitor to wake
113 up the event loop via the file descriptor this
114 function needs to be called to reset the wake-up
115 state. If this call is not invoked the file descriptor
116 will immediately wake up the event loop again.</para>
117
118 <para><function>sd_login_monitor_get_fd()</function>
119 may be used to retrieve the file descriptor of the
120 monitor object that may be integrated in an
121 application defined event loop, based around
122 <citerefentry><refentrytitle>poll</refentrytitle><manvolnum>2</manvolnum></citerefentry>
123 or a similar interface. The application should include
124 the returned file descriptor as wake up source for
125 POLLIN events. Whenever a wake-up is triggered the
126 file descriptor needs to be reset via
127 <function>sd_login_monitor_flush()</function>. An
128 application needs to reread the login state with a
129 function like
130 <citerefentry><refentrytitle>sd_get_seats</refentrytitle><manvolnum>3</manvolnum></citerefentry>
131 or similar to determine what changed.</para>
132 </refsect1>
133
134 <refsect1>
135 <title>Return Value</title>
136
137 <para>On success
138 <function>sd_login_monitor_new()</function> and
139 <function>sd_login_monitor_flush()</function> return 0
140 or a positive integer. On success
141 <function>sd_login_monitor_get_fd()</function> returns
142 a Unix file descriptor. On failure, these calls return
143 a negative errno-style error code.</para>
144
145 <para><function>sd_login_monitor_unref()</function>
146 always returns NULL.</para>
147 </refsect1>
148
149 <refsect1>
150 <title>Notes</title>
151
152 <para>The <function>sd_login_monitor_new()</function>,
153 <function>sd_login_monitor_unref()</function>, <function>sd_login_monitor_flush()</function> and
154 <function>sd_login_monitor_get_fd()</function> interfaces
155 are available as shared library, which can be compiled
156 and linked to with the
157 <literal>libsystemd-login</literal>
158 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
159 file.</para>
160 </refsect1>
161
162 <refsect1>
163 <title>See Also</title>
164
165 <para>
166 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
167 <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
595aae37 168 <citerefentry><refentrytitle>sd_get_seats</refentrytitle><manvolnum>3</manvolnum></citerefentry>
0b3b020a
LP
169 </para>
170 </refsect1>
171
172</refentry>