pub struct ExecSession { /* private fields */ }Expand description
An active exec session handle for sending input to a running process.
Output reading is handled by a background task that sends events
via the mpsc channel provided at spawn time.
Implementations§
Source§impl ExecSession
impl ExecSession
Sourcepub fn spawn(
id: u32,
req: &ExecRequest,
tx: UnboundedSender<(u32, SessionOutput)>,
default_user: Option<&str>,
security_profile: SecurityProfile,
) -> AgentdResult<Self>
pub fn spawn( id: u32, req: &ExecRequest, tx: UnboundedSender<(u32, SessionOutput)>, default_user: Option<&str>, security_profile: SecurityProfile, ) -> AgentdResult<Self>
Spawns a new exec session.
If req.tty is true, uses a PTY. Otherwise, uses piped stdin/stdout/stderr.
A background task is spawned to read output and send events via tx.
Sourcepub async fn write_stdin(&self, data: &[u8]) -> AgentdResult<()>
pub async fn write_stdin(&self, data: &[u8]) -> AgentdResult<()>
Writes data to the process’s stdin (or PTY master).
Sourcepub fn resize(&self, rows: u16, cols: u16) -> AgentdResult<()>
pub fn resize(&self, rows: u16, cols: u16) -> AgentdResult<()>
Resizes the PTY (only applicable for TTY sessions).
Sourcepub fn send_signal(&self, signum: i32) -> AgentdResult<()>
pub fn send_signal(&self, signum: i32) -> AgentdResult<()>
Sends a signal to the spawned process and everything it started.
The child is made a session leader at spawn (both pipe and PTY modes),
so signalling the negative pid reaches its whole process group. A bare
kill(pid) here leaked orphans: killing sh -c "job &" took out the
shell while its backgrounded children survived reparented to init,
silently accumulating load in the guest.
Sourcepub fn close_stdin(&mut self)
pub fn close_stdin(&mut self)
Closes the process’s stdin.
For pipe mode, drops the ChildStdin handle which closes the fd.
For PTY mode, this is a no-op (the PTY master stays open for output).