402N/A<?
xml version='1.0'?>
<!--*-nxml-*--> 402N/A<!
DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 402N/A This file is part of systemd. 402N/A Copyright 2010 Lennart Poettering 402N/A systemd is free software; you can redistribute it and/or modify it 402N/A under the terms of the GNU General Public License as published by 402N/A the Free Software Foundation; either version 2 of the License, or 402N/A (at your option) any later version. 402N/A systemd is distributed in the hope that it will be useful, but 402N/A WITHOUT ANY WARRANTY; without even the implied warranty of 402N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 402N/A General Public License for more details. 402N/A You should have received a copy of the GNU General Public License 814N/A<
refentry id="sd_pid_get_session">
814N/A <
title>sd_pid_get_session</
title>
402N/A <
productname>systemd</
productname>
402N/A <
contrib>Developer</
contrib>
402N/A <
firstname>Lennart</
firstname>
618N/A <
surname>Poettering</
surname>
402N/A <
email>lennart@poettering.net</
email>
1407N/A <
refentrytitle>sd_pid_get_session</
refentrytitle>
402N/A <
manvolnum>3</
manvolnum>
814N/A <
refname>sd_pid_get_session</
refname>
3817N/A <
refname>sd_pid_get_owner_uid</
refname>
3817N/A <
refpurpose>Determine session or owner of a session of a specific PID</
refpurpose>
3955N/A <
funcdef>int <
function>sd_pid_get_session</
function></
funcdef>
3955N/A <
paramdef>pid_t <
parameter>pid</
parameter></
paramdef>
3955N/A <
paramdef>char** <
parameter>session</
parameter></
paramdef>
3955N/A <
funcdef>int <
function>sd_pid_get_owner_uid</
function></
funcdef>
3955N/A <
paramdef>pid_t <
parameter>pid</
parameter></
paramdef>
3955N/A <
paramdef>uid_t* <
parameter>uid</
parameter></
paramdef>
402N/A <
title>Description</
title>
402N/A <
para><
function>sd_pid_get_session()</
function> may be
402N/A used to determine the login session identifier of a
402N/A process identified by the specified process identifier. The session
402N/A identifier is a short string (up to 64 characters),
402N/A consisting only of the characters a-zA-Z0-9 as well as
402N/A '-' and '_'. It is suitable for usage in file system
402N/A paths. Note that not all processes are part of a login
402N/A session (
e.g. system service processes and user
402N/A processes that are shared between multiple sessions of
402N/A the same user). For processes not being part of a
402N/A login session this function will fail. The returned
402N/A string needs to be freed with the libc
402N/A <
citerefentry><
refentrytitle>free</
refentrytitle><
manvolnum>3</
manvolnum></
citerefentry>
402N/A <
para><
function>sd_pid_get_owner_uid()</
function> may
402N/A be used to determine the Unix user identifier of the
402N/A owner of the session of a process identified the
402N/A specified PID. Note that this function will succeed
402N/A for user processes which are shared between multiple
402N/A login sessions of the same user, where
402N/A <
function>sd_pid_get_session()</
function> will
402N/A fail. For processes not being part of a login session
402N/A and not being a shared process of a user this function
402N/A <
title>Return Value</
title>
402N/A <
para>On success these calls return 0 or a positive
402N/A integer. On failure, these calls return a negative
402N/A errno-style error code.</
para>
402N/A <
para>The <
function>sd_pid_get_session()</
function>
402N/A and <
function>sd_pid_get_owner_uid()</
function>
402N/A interfaces are available as shared library, which can
402N/A be compiled and linked to with the
402N/A <
literal>libsystemd-login</
literal>
402N/A <
citerefentry><
refentrytitle>pkg-config</
refentrytitle><
manvolnum>1</
manvolnum></
citerefentry>
402N/A <
para>Note that the login session identifier as
402N/A returned by <
function>sd_pid_get_session()</
function>
402N/A is completely unrelated to the process session
402N/A identifier as returned by
402N/A <
citerefentry><
refentrytitle>getsid</
refentrytitle><
manvolnum>2</
manvolnum></
citerefentry>.</
para>
402N/A <
title>See Also</
title>
402N/A <
citerefentry><
refentrytitle>systemd</
refentrytitle><
manvolnum>1</
manvolnum></
citerefentry>,
402N/A <
citerefentry><
refentrytitle>sd-login</
refentrytitle><
manvolnum>7</
manvolnum></
citerefentry>,
4496N/A <
citerefentry><
refentrytitle>sd_session_is_active</
refentrytitle><
manvolnum>3</
manvolnum></
citerefentry>,
402N/A <
citerefentry><
refentrytitle>getsid</
refentrytitle><
manvolnum>2</
manvolnum></
citerefentry>