| 1 |
'\" t |
| 2 |
.TH "SD_EVENT_SOURCE_SET_DESTROY_CALLBACK" "3" "" "systemd 261~rc3" "sd_event_source_set_destroy_callback" |
| 3 |
.\" ----------------------------------------------------------------- |
| 4 |
.\" * Define some portability stuff |
| 5 |
.\" ----------------------------------------------------------------- |
| 6 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 7 |
.\" http://bugs.debian.org/507673 |
| 8 |
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html |
| 9 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 |
.ie \n(.g .ds Aq \(aq |
| 11 |
.el .ds Aq ' |
| 12 |
.\" ----------------------------------------------------------------- |
| 13 |
.\" * set default formatting |
| 14 |
.\" ----------------------------------------------------------------- |
| 15 |
.\" disable hyphenation |
| 16 |
.nh |
| 17 |
.\" disable justification (adjust text to left margin only) |
| 18 |
.ad l |
| 19 |
.\" ----------------------------------------------------------------- |
| 20 |
.\" * MAIN CONTENT STARTS HERE * |
| 21 |
.\" ----------------------------------------------------------------- |
| 22 |
.SH "NAME" |
| 23 |
sd_event_source_set_destroy_callback, sd_event_source_get_destroy_callback, sd_event_destroy_t \- Define the callback function for resource cleanup |
| 24 |
.SH "SYNOPSIS" |
| 25 |
.sp |
| 26 |
.ft B |
| 27 |
.nf |
| 28 |
#include <systemd/sd\-event\&.h> |
| 29 |
.fi |
| 30 |
.ft |
| 31 |
.HP \w'typedef\ int\ (*sd_event_destroy_t)('u |
| 32 |
.BI "typedef int (*sd_event_destroy_t)(void\ *" "userdata" ");" |
| 33 |
.HP \w'int\ sd_event_source_set_destroy_callback('u |
| 34 |
.BI "int sd_event_source_set_destroy_callback(sd_event_source\ *" "source" ", sd_event_destroy_t\ " "callback" ");" |
| 35 |
.HP \w'int\ sd_event_source_get_destroy_callback('u |
| 36 |
.BI "int sd_event_source_get_destroy_callback(sd_event_source\ *" "source" ", sd_event_destroy_t\ *" "callback" ");" |
| 37 |
.SH "DESCRIPTION" |
| 38 |
.PP |
| 39 |
\fBsd_event_source_set_destroy_callback()\fR |
| 40 |
sets |
| 41 |
\fIcallback\fR |
| 42 |
as the callback function to be called right before the event source object |
| 43 |
\fIsource\fR |
| 44 |
is deallocated\&. The |
| 45 |
\fIuserdata\fR |
| 46 |
pointer from the event source object will be passed as the |
| 47 |
\fIuserdata\fR |
| 48 |
parameter\&. This pointer can be set by an argument to the constructor functions, see |
| 49 |
\fBsd_event_add_io\fR(3), or directly, see |
| 50 |
\fBsd_event_source_set_userdata\fR(3)\&. This callback function is called even if |
| 51 |
\fIuserdata\fR |
| 52 |
is |
| 53 |
\fBNULL\fR\&. Note that this callback is invoked at a time where the event source object itself is already invalidated, and executing operations or taking new references to the event source object is not permissible\&. |
| 54 |
.PP |
| 55 |
\fBsd_event_source_get_destroy_callback()\fR |
| 56 |
returns the current callback for |
| 57 |
\fIsource\fR |
| 58 |
in the |
| 59 |
\fIcallback\fR |
| 60 |
parameter\&. |
| 61 |
.SH "RETURN VALUE" |
| 62 |
.PP |
| 63 |
On success, |
| 64 |
\fBsd_event_source_set_destroy_callback()\fR |
| 65 |
returns 0 or a positive integer\&. On failure, it returns a negative errno\-style error code\&. |
| 66 |
.PP |
| 67 |
\fBsd_event_source_get_destroy_callback()\fR |
| 68 |
returns positive if the destroy callback function is set, 0 if not\&. On failure, returns a negative errno\-style error code\&. |
| 69 |
.SS "Errors" |
| 70 |
.PP |
| 71 |
Returned errors may indicate the following problems: |
| 72 |
.PP |
| 73 |
\fB\-EINVAL\fR |
| 74 |
.RS 4 |
| 75 |
The |
| 76 |
\fIsource\fR |
| 77 |
parameter is |
| 78 |
\fBNULL\fR\&. |
| 79 |
.RE |
| 80 |
.SH "NOTES" |
| 81 |
.PP |
| 82 |
Functions described here are available as a shared library, which can be compiled against and linked to with the |
| 83 |
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1) |
| 84 |
file\&. |
| 85 |
.PP |
| 86 |
The code described here uses |
| 87 |
\fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call |
| 88 |
\fBsetenv\fR(3) |
| 89 |
from a parallel thread\&. It is recommended to only do calls to |
| 90 |
\fBsetenv()\fR |
| 91 |
from an early phase of the program when no other threads have been started\&. |
| 92 |
.SH "HISTORY" |
| 93 |
.PP |
| 94 |
\fBsd_event_destroy_t()\fR, |
| 95 |
\fBsd_event_source_set_destroy_callback()\fR, and |
| 96 |
\fBsd_event_source_get_destroy_callback()\fR |
| 97 |
were added in version 239\&. |
| 98 |
.SH "SEE ALSO" |
| 99 |
.PP |
| 100 |
\fBsystemd\fR(1), \fBsd-event\fR(3), \fBsd_event_add_io\fR(3), \fBsd_event_add_time\fR(3), \fBsd_event_add_signal\fR(3), \fBsd_event_add_child\fR(3), \fBsd_event_add_inotify\fR(3), \fBsd_event_add_defer\fR(3), \fBsd_event_source_set_userdata\fR(3) |