pub struct PtySpawner { /* private fields */ }Expand description
Spawner for PTY sessions.
Implementations§
Source§impl PtySpawner
impl PtySpawner
Sourcepub const fn with_config(config: PtyConfig) -> Self
pub const fn with_config(config: PtyConfig) -> Self
Create a new PTY spawner with custom configuration.
Sourcepub const fn set_dimensions(&mut self, cols: u16, rows: u16)
pub const fn set_dimensions(&mut self, cols: u16, rows: u16)
Set the terminal dimensions.
Sourcepub async fn spawn(&self, command: &str, args: &[String]) -> Result<PtyHandle>
pub async fn spawn(&self, command: &str, args: &[String]) -> Result<PtyHandle>
Spawn a command.
§Runtime requirement (Unix)
The Unix implementation forks and then calls setenv / unsetenv /
clearenv between fork and exec to apply the configured env mode.
Those libc functions are not async-signal-safe — they allocate
— so the post-fork window in the child must run on a single thread
for the call to be sound. In this crate that is true because
callers reach spawn directly from a fresh tokio::main or
equivalent before any background thread has captured the
allocator lock at the fork point.
If you embed this crate in a host that pre-spawns worker
threads (for example, a multi-threaded scheduler that’s already
running by the time you call Session::spawn), the assumption
breaks: another thread may hold the allocator lock at the moment
of fork, and the child can deadlock or corrupt heap state on
the first setenv call. In that environment, prefer a
posix_spawn-based spawner or a pre-fork sentinel-pipe helper.
§Errors
Returns an error if:
- The command or arguments contain null bytes
- PTY allocation fails
- Fork fails
- Exec fails (child exits with code 1)