pub struct TtySpawn { /* private fields */ }Expand description
Lets you spawn processes with a TTY connected.
Implementations§
Source§impl TtySpawn
impl TtySpawn
Sourcepub fn new_cmdline<S: AsRef<OsStr>, I: Iterator<Item = S>>(cmdline: I) -> Self
pub fn new_cmdline<S: AsRef<OsStr>, I: Iterator<Item = S>>(cmdline: I) -> Self
Sourcepub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
Adds a new argument to the command.
Sourcepub fn args<S: AsRef<OsStr>, I: Iterator<Item = S>>(
&mut self,
args: I,
) -> &mut Self
pub fn args<S: AsRef<OsStr>, I: Iterator<Item = S>>( &mut self, args: I, ) -> &mut Self
Adds multiple arguments from an iterator.
Sourcepub fn stdin_file(&mut self, f: File) -> &mut Self
pub fn stdin_file(&mut self, f: File) -> &mut Self
Sets an input file for stdin.
It’s recommended that this is a named pipe and as a general recommendation
this file should be opened with O_NONBLOCK.
§Platform Specifics
While we will never write into the file it’s strongly recommended to
ensure that the file is opened writable too. The reason for this is that
on Linux, if the last writer (temporarily) disconnects from a FIFO polling
primitives such as the one used by tty-spawn will keep reporting that the
file is ready while there not actually being any more data coming in. The
solution to this problem is to ensure that there is at least always one
writer open which can be ensured by also opening this file for writing.
Sourcepub fn stdin_path<P: AsRef<Path>>(
&mut self,
path: P,
) -> Result<&mut Self, Error>
pub fn stdin_path<P: AsRef<Path>>( &mut self, path: P, ) -> Result<&mut Self, Error>
Sets a path as input file for stdin.
Sourcepub fn stdout_file(&mut self, f: File) -> &mut Self
pub fn stdout_file(&mut self, f: File) -> &mut Self
Sets an output file for stdout.
Sourcepub fn stdout_path<P: AsRef<Path>>(
&mut self,
path: P,
truncate: bool,
) -> Result<&mut Self, Error>
pub fn stdout_path<P: AsRef<Path>>( &mut self, path: P, truncate: bool, ) -> Result<&mut Self, Error>
Sets a path as output file for stdout.
If the truncate flag is set to true the file will be truncated
first, otherwise it will be appended to.
Sourcepub fn script_mode(&mut self, yes: bool) -> &mut Self
pub fn script_mode(&mut self, yes: bool) -> &mut Self
Enables script mode.
In script mode stdout/stderr are retained as separate streams, the terminal is not opened in raw mode. Additionally some output processing is disabled so usually you will find LF retained and not converted to CLRF. This will also attempt to disable pagers and turn off ECHO intelligently in some cases.
Sourcepub fn flush(&mut self, yes: bool) -> &mut Self
pub fn flush(&mut self, yes: bool) -> &mut Self
Can be used to turn flushing off.
By default output is flushed constantly.
Sourcepub fn echo(&mut self, yes: bool) -> &mut Self
pub fn echo(&mut self, yes: bool) -> &mut Self
Can be used to turn echo off.
By default echo is turned on.
Sourcepub fn pager(&mut self, yes: bool) -> &mut Self
pub fn pager(&mut self, yes: bool) -> &mut Self
Tries to use cat as pager.
When this is enabled then processes are instructed to use cat as pager.
This is useful when raw terminals are disabled in which case most pagers
will break.