]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_event_source_set_destroy_callback.xml
travis: use UBSan checks from OSS-Fuzz
[thirdparty/systemd.git] / man / sd_event_source_set_destroy_callback.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
3a54a157
ZJS
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
15723a1d
LP
4<!-- SPDX-License-Identifier: LGPL-2.1+ -->
5
6<refentry id="sd_event_source_set_destroy_callback"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>sd_event_source_set_destroy_callback</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>sd_event_source_set_destroy_callback</refentrytitle>
16 <manvolnum>3</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>sd_event_source_set_destroy_callback</refname>
21 <refname>sd_event_source_get_destroy_callback</refname>
22 <refname>sd_event_destroy_t</refname>
23
24 <refpurpose>Define the callback function for resource cleanup.</refpurpose>
25 </refnamediv>
26
27 <refsynopsisdiv>
28 <funcsynopsis>
29 <funcsynopsisinfo>#include &lt;systemd/sd-event.h&gt;</funcsynopsisinfo>
30
31 <funcprototype>
32 <funcdef>typedef int (*<function>sd_event_destroy_t</function>)</funcdef>
33 <paramdef>void *<parameter>userdata</parameter></paramdef>
34 </funcprototype>
35
36 <funcprototype>
37 <funcdef>int <function>sd_event_source_set_destroy_callback</function></funcdef>
38 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
39 <paramdef>sd_event_destroy_t <parameter>callback</parameter></paramdef>
40 </funcprototype>
41
42 <funcprototype>
43 <funcdef>int <function>sd_event_source_get_destroy_callback</function></funcdef>
44 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
45 <paramdef>sd_event_destroy_t *<parameter>callback</parameter></paramdef>
46 </funcprototype>
47
48 </funcsynopsis>
49 </refsynopsisdiv>
50
51 <refsect1>
52 <title>Description</title>
53
54 <para><function>sd_event_source_set_destroy_callback()</function> sets <parameter>callback</parameter> as the
55 callback function to be called right before the event source object <parameter>source</parameter> is
56 deallocated. The <parameter>userdata</parameter> pointer from the event source object will be passed as the
57 <parameter>userdata</parameter> parameter. This pointer can be set by an argument to the constructor functions, see
58 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>, or directly,
59 see
60 <citerefentry><refentrytitle>sd_event_source_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
61 This callback function is called even if <parameter>userdata</parameter> is <constant>NULL</constant>. Note that
62 this callback is invoked at a time where the event source object itself is already invalidated, and executing
63 operations or taking new references to the event source object is not permissible.</para>
64
65 <para><function>sd_event_source_get_destroy_callback()</function> returns the current callback
66 for <parameter>source</parameter> in the <parameter>callback</parameter> parameter.</para>
67 </refsect1>
68
69 <refsect1>
70 <title>Return Value</title>
71
b1de39de
ZJS
72 <para>On success, <function>sd_event_source_set_destroy_callback()</function> returns 0 or a positive
73 integer. On failure, it returns a negative errno-style error code.</para>
15723a1d 74
b1de39de
ZJS
75 <para><function>sd_event_source_get_destroy_callback()</function> returns positive if the destroy
76 callback function is set, 0 if not. On failure, returns a negative errno-style error code.</para>
15723a1d 77
b1de39de
ZJS
78 <refsect2>
79 <title>Errors</title>
15723a1d 80
b1de39de 81 <para>Returned errors may indicate the following problems:</para>
15723a1d 82
b1de39de
ZJS
83 <variablelist>
84 <varlistentry>
85 <term><constant>-EINVAL</constant></term>
15723a1d 86
b1de39de
ZJS
87 <listitem><para>The <parameter>source</parameter> parameter is <constant>NULL</constant>.
88 </para></listitem>
89 </varlistentry>
90 </variablelist>
91 </refsect2>
15723a1d
LP
92 </refsect1>
93
94 <xi:include href="libsystemd-pkgconfig.xml" />
95
96 <refsect1>
97 <title>See Also</title>
98
99 <para>
100 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
101 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
102 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
103 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
104 <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
105 <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
106 <citerefentry><refentrytitle>sd_event_add_inotify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
107 <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
108 <citerefentry><refentrytitle>sd_event_source_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>
109 </para>
110 </refsect1>
111
112</refentry>