summaryrefslogtreecommitdiff
path: root/src/login/logind-session.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-06-21 16:14:53 +0200
committerLennart Poettering <lennart@poettering.net>2012-06-21 16:14:53 +0200
commit0604381b9dbef4cc498b5a77311e1da99c1430b8 (patch)
treeec766081c20d07ddd17c825d42569fbddefdcbe8 /src/login/logind-session.c
parentf1a8e221ecacea23883df57951e291a910463948 (diff)
logind: introduce a state for session, being one of online, active, closing
online = logged in active = logged in and session is in the fg closing = nominally logged out but some left-over processes still around Related to: https://bugzilla.gnome.org/show_bug.cgi?id=677556
Diffstat (limited to 'src/login/logind-session.c')
-rw-r--r--src/login/logind-session.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 58514ea0d2..e438c66332 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -133,11 +133,13 @@ int session_save(Session *s) {
"UID=%lu\n"
"USER=%s\n"
"ACTIVE=%i\n"
+ "STATE=%s\n"
"REMOTE=%i\n"
"KILL_PROCESSES=%i\n",
(unsigned long) s->user->uid,
s->user->name,
session_is_active(s),
+ session_state_to_string(session_get_state(s)),
s->remote,
s->kill_processes);
@@ -913,6 +915,18 @@ void session_add_to_gc_queue(Session *s) {
s->in_gc_queue = true;
}
+SessionState session_get_state(Session *s) {
+ assert(s);
+
+ if (s->fifo_fd < 0)
+ return SESSION_CLOSING;
+
+ if (session_is_active(s))
+ return SESSION_ACTIVE;
+
+ return SESSION_ONLINE;
+}
+
int session_kill(Session *s, KillWho who, int signo) {
int r = 0;
Set *pid_set = NULL;
@@ -954,6 +968,14 @@ int session_kill(Session *s, KillWho who, int signo) {
return r;
}
+static const char* const session_state_table[_SESSION_TYPE_MAX] = {
+ [SESSION_ONLINE] = "online",
+ [SESSION_ACTIVE] = "active",
+ [SESSION_CLOSING] = "closing"
+};
+
+DEFINE_STRING_TABLE_LOOKUP(session_state, SessionState);
+
static const char* const session_type_table[_SESSION_TYPE_MAX] = {
[SESSION_TTY] = "tty",
[SESSION_X11] = "x11",