| 1 |
'\" t |
| 2 |
.TH "SD_SEAT_GET_ACTIVE" "3" "" "systemd 261~rc3" "sd_seat_get_active" |
| 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_seat_get_active, sd_seat_get_sessions, sd_seat_can_tty, sd_seat_can_graphical \- Determine state of a specific seat |
| 24 |
.SH "SYNOPSIS" |
| 25 |
.sp |
| 26 |
.ft B |
| 27 |
.nf |
| 28 |
#include <systemd/sd\-login\&.h> |
| 29 |
.fi |
| 30 |
.ft |
| 31 |
.HP \w'int\ sd_seat_get_active('u |
| 32 |
.BI "int sd_seat_get_active(const\ char\ *" "seat" ", char\ **" "session" ", uid_t\ *" "uid" ");" |
| 33 |
.HP \w'int\ sd_seat_get_sessions('u |
| 34 |
.BI "int sd_seat_get_sessions(const\ char\ *" "seat" ", char\ ***" "ret_sessions" ", uid_t\ **" "ret_uids" ", unsigned\ int\ *" "ret_n_uids" ");" |
| 35 |
.HP \w'int\ sd_seat_can_tty('u |
| 36 |
.BI "int sd_seat_can_tty(const\ char\ *" "seat" ");" |
| 37 |
.HP \w'int\ sd_seat_can_graphical('u |
| 38 |
.BI "int sd_seat_can_graphical(const\ char\ *" "seat" ");" |
| 39 |
.SH "DESCRIPTION" |
| 40 |
.PP |
| 41 |
\fBsd_seat_get_active()\fR |
| 42 |
may be used to determine which session is currently active on a seat, if there is any\&. Returns the session identifier and the user identifier of the Unix user the session is belonging to\&. Either the session or the user identifier parameter can be passed |
| 43 |
\fBNULL\fR, in case only one of the parameters shall be queried\&. The returned string needs to be freed with the libc |
| 44 |
\fBfree\fR(3) |
| 45 |
call after use\&. |
| 46 |
.PP |
| 47 |
\fBsd_seat_get_sessions()\fR |
| 48 |
may be used to determine all sessions on the specified seat\&. Returns two arrays, one (\fBNULL\fR |
| 49 |
terminated) with the session identifiers of the sessions and one with the user identifiers of the Unix users the sessions belong to\&. An additional parameter may be used to return the number of entries in the latter array\&. This value is the same as the return value if the return value is nonnegative\&. The output parameters may be passed as |
| 50 |
\fBNULL\fR |
| 51 |
in case these output values are not needed\&. The arrays and the strings referenced by them need to be freed with the libc |
| 52 |
\fBfree\fR(3) |
| 53 |
call after use\&. Note that instead of an empty array |
| 54 |
\fBNULL\fR |
| 55 |
may be returned and should be considered equivalent to an empty array\&. |
| 56 |
.PP |
| 57 |
\fBsd_seat_can_tty()\fR |
| 58 |
may be used to determine whether a specific seat provides TTY functionality, i\&.e\&. is useful as a text console\&. |
| 59 |
.PP |
| 60 |
\fBsd_seat_can_graphical()\fR |
| 61 |
may be used to determine whether a specific seat provides graphics functionality, i\&.e\&. is useful as a graphics display\&. |
| 62 |
.PP |
| 63 |
If the |
| 64 |
\fIseat\fR |
| 65 |
parameter of any of these functions is passed as |
| 66 |
\fBNULL\fR, the operation is executed for the seat of the session of the calling process, if there is any\&. |
| 67 |
.SH "RETURN VALUE" |
| 68 |
.PP |
| 69 |
On success, |
| 70 |
\fBsd_seat_get_active()\fR |
| 71 |
returns 0 or a positive integer\&. On success, |
| 72 |
\fBsd_seat_get_sessions()\fR |
| 73 |
returns the number of entries in the session identifier array\&. If the test succeeds, |
| 74 |
\fBsd_seat_can_tty()\fR |
| 75 |
and |
| 76 |
\fBsd_seat_can_graphical()\fR |
| 77 |
return a positive integer, if it fails 0\&. On failure, these calls return a negative errno\-style error code\&. |
| 78 |
.SS "Errors" |
| 79 |
.PP |
| 80 |
Returned errors may indicate the following problems: |
| 81 |
.PP |
| 82 |
\fB\-ENODATA\fR |
| 83 |
.RS 4 |
| 84 |
The given field is not specified for the described seat\&. |
| 85 |
.RE |
| 86 |
.PP |
| 87 |
\fB\-ENXIO\fR |
| 88 |
.RS 4 |
| 89 |
The specified seat is unknown\&. |
| 90 |
.RE |
| 91 |
.PP |
| 92 |
\fB\-EINVAL\fR |
| 93 |
.RS 4 |
| 94 |
An input parameter was invalid (out of range, or |
| 95 |
\fBNULL\fR, where that is not accepted)\&. |
| 96 |
.RE |
| 97 |
.PP |
| 98 |
\fB\-ENOMEM\fR |
| 99 |
.RS 4 |
| 100 |
Memory allocation failed\&. |
| 101 |
.RE |
| 102 |
.SH "NOTES" |
| 103 |
.PP |
| 104 |
Functions described here are available as a shared library, which can be compiled against and linked to with the |
| 105 |
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1) |
| 106 |
file\&. |
| 107 |
.PP |
| 108 |
The code described here uses |
| 109 |
\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 |
| 110 |
\fBsetenv\fR(3) |
| 111 |
from a parallel thread\&. It is recommended to only do calls to |
| 112 |
\fBsetenv()\fR |
| 113 |
from an early phase of the program when no other threads have been started\&. |
| 114 |
.SH "HISTORY" |
| 115 |
.PP |
| 116 |
\fBsd_seat_can_tty()\fR |
| 117 |
and |
| 118 |
\fBsd_seat_can_graphical()\fR |
| 119 |
were added in version 186\&. |
| 120 |
.SH "SEE ALSO" |
| 121 |
.PP |
| 122 |
\fBsystemd\fR(1), \fBsd-login\fR(3), \fBsd_session_get_seat\fR(3) |