pub struct SessionManager { /* private fields */ }Expand description
Manages all active sessions.
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn create_session(
&mut self,
user_id: u64,
username: &str,
vt: u8,
) -> Result<SessionId, KernelError>
pub fn create_session( &mut self, user_id: u64, username: &str, vt: u8, ) -> Result<SessionId, KernelError>
Create a new session for a user.
Assigns the next available virtual terminal starting at VT_BASE.
Returns Err if the maximum number of sessions is reached.
Sourcepub fn destroy_session(&mut self, id: SessionId)
pub fn destroy_session(&mut self, id: SessionId)
Destroy a session and remove it from tracking.
Sourcepub fn get_session(&self, id: SessionId) -> Option<&Session>
pub fn get_session(&self, id: SessionId) -> Option<&Session>
Get a reference to a session by ID.
Sourcepub fn get_session_mut(&mut self, id: SessionId) -> Option<&mut Session>
pub fn get_session_mut(&mut self, id: SessionId) -> Option<&mut Session>
Get a mutable reference to a session by ID.
Sourcepub fn get_active_session(&self) -> Option<SessionId>
pub fn get_active_session(&self) -> Option<SessionId>
Return the currently active (foreground) session ID.
Sourcepub fn switch_session(&mut self, id: SessionId)
pub fn switch_session(&mut self, id: SessionId)
Switch to a different session.
The previously active session is moved to Background; the new
session becomes Active.
Sourcepub fn lock_session(&mut self, id: SessionId)
pub fn lock_session(&mut self, id: SessionId)
Lock a session (requires re-authentication to resume).
Sourcepub fn unlock_session(&mut self, id: SessionId)
pub fn unlock_session(&mut self, id: SessionId)
Unlock a previously locked session, returning it to Active.
Sourcepub fn add_process(&mut self, session_id: SessionId, pid: ProcessId)
pub fn add_process(&mut self, session_id: SessionId, pid: ProcessId)
Add a process to a session.
Sourcepub fn remove_process(&mut self, session_id: SessionId, pid: ProcessId)
pub fn remove_process(&mut self, session_id: SessionId, pid: ProcessId)
Remove a process from a session.
Sourcepub fn get_session_for_vt(&self, vt: u8) -> Option<SessionId>
pub fn get_session_for_vt(&self, vt: u8) -> Option<SessionId>
Find the session assigned to a given VT number.
Sourcepub fn list_sessions(&self) -> Vec<SessionId>
pub fn list_sessions(&self) -> Vec<SessionId>
Return a list of all session IDs.
Sourcepub fn session_count(&self) -> usize
pub fn session_count(&self) -> usize
Number of active sessions.
Sourcepub fn can_signal(&self, source_pid: u64, target_pid: u64) -> bool
pub fn can_signal(&self, source_pid: u64, target_pid: u64) -> bool
Check whether a process in one session may signal a process in another.
Session isolation: cross-session signaling is denied unless the source process belongs to the same session as the target.
Sourcepub fn begin_logout(&mut self, id: SessionId)
pub fn begin_logout(&mut self, id: SessionId)
Begin logout for a session: set state to LoggingOut.
Sourcepub fn get_session_processes(&self, id: SessionId) -> Vec<u64>
pub fn get_session_processes(&self, id: SessionId) -> Vec<u64>
Get all process IDs belonging to a session (for cleanup on logout).