'\" t .\" Title: sd_login_monitor_new .\" Author: Lennart Poettering .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 10/07/2013 .\" Manual: sd_login_monitor_new .\" Source: systemd .\" Language: English .\" .TH "SD_LOGIN_MONITOR_NEW" "3" "10/07/2013" "systemd" "sd_login_monitor_new" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" sd_login_monitor_new, sd_login_monitor_unref, sd_login_monitor_flush, sd_login_monitor_get_fd \- Monitor login sessions, seats and users .SH "SYNOPSIS" .sp .ft B .nf #include .fi .ft .HP \w'int\ sd_login_monitor_new('u .BI "int sd_login_monitor_new(const\ char*\ " "category" ", sd_login_monitor**\ " "ret" ");" .HP \w'sd_login_monitor*\ sd_login_monitor_unref('u .BI "sd_login_monitor* sd_login_monitor_unref(sd_login_monitor*\ " "m" ");" .HP \w'int\ sd_login_monitor_flush('u .BI "int sd_login_monitor_flush(sd_login_monitor*\ " "m" ");" .HP \w'int\ sd_login_monitor_get_fd('u .BI "int sd_login_monitor_get_fd(sd_login_monitor*\ " "m" ");" .SH "DESCRIPTION" .PP \fBsd_login_monitor_new()\fR may be used to monitor login session, users and seats\&. Via a monitor object a file descriptor can be integrated into an application defined event loop which is woken up each time a user logs in, logs out or a seat is added or removed, or a session, user, or seat changes state otherwise\&. The first parameter takes a string which can be either seat (to get only notifications about seats being added, removed or changed), session (to get only notifications about sessions being created or removed or changed) or uid (to get only notifications when a user changes state in respect to logins)\&. If notifications shall be generated in all these conditions, NULL may be passed\&. Note that in future additional categories may be defined\&. The second parameter returns a monitor object and needs to be freed with the \fBsd_login_monitor_unref()\fR call after use\&. .PP \fBsd_login_monitor_unref()\fR may be used to destroy a monitor object\&. Note that this will invalidate any file descriptor returned by \fBsd_login_monitor_get_fd()\fR\&. .PP \fBsd_login_monitor_flush()\fR may be used to reset the wakeup state of the monitor object\&. Whenever an event causes the monitor to wake up the event loop via the file descriptor this function needs to be called to reset the wake\-up state\&. If this call is not invoked the file descriptor will immediately wake up the event loop again\&. .PP \fBsd_login_monitor_get_fd()\fR may be used to retrieve the file descriptor of the monitor object that may be integrated in an application defined event loop, based around \fBpoll\fR(2) or a similar interface\&. The application should include the returned file descriptor as wake up source for POLLIN events\&. Whenever a wake\-up is triggered the file descriptor needs to be reset via \fBsd_login_monitor_flush()\fR\&. An application needs to reread the login state with a function like \fBsd_get_seats\fR(3) or similar to determine what changed\&. .SH "RETURN VALUE" .PP On success \fBsd_login_monitor_new()\fR and \fBsd_login_monitor_flush()\fR return 0 or a positive integer\&. On success \fBsd_login_monitor_get_fd()\fR returns a Unix file descriptor\&. On failure, these calls return a negative errno\-style error code\&. .PP \fBsd_login_monitor_unref()\fR always returns NULL\&. .SH "NOTES" .PP The \fBsd_login_monitor_new()\fR, \fBsd_login_monitor_unref()\fR, \fBsd_login_monitor_flush()\fR and \fBsd_login_monitor_get_fd()\fR interfaces are available as shared library, which can be compiled and linked to with the libsystemd\-login \fBpkg-config\fR(1) file\&. .SH "SEE ALSO" .PP \fBsystemd\fR(1), \fBsd-login\fR(7), \fBsd_get_seats\fR(3) .SH "AUTHOR" .PP \fBLennart Poettering\fR <\&lennart@poettering\&.net\&> .RS 4 Developer .RE