Closed Michael-F-Bryan closed 7 years ago
Hi Michael. Sorry for the delay, just got back from my holidays (without internet ;-)), I'll look into this in the next days.
Ah, the members of PtySession need to be public. Totally forgot about that. I now changed that and pushed to crates.io, so you can do now e.g. this:
extern crate rexpect;
use rexpect::spawn;
use rexpect::process::signal;
use rexpect::errors::*;
fn do_sleep() -> Result<()> {
let mut p = spawn("sleep 999", Some(2000))?;
p.process.signal(signal::SIGINT)?;
Ok(())
}
fn main() {
do_sleep().unwrap_or_else(|e| panic!("ftp job failed with {}", e));
}
Closing this as I believe @Michael-F-Bryan your issue is fixed, right?
Yep. Sorry, I probably should have closed this as solved once I saw your reply about pushing a fix to crates.io.
no worries. I'm glad there are even people using this crate :-)
I notice you can send a control character like
<ctrl-c>
for keyboard interrupt, or<ctrl-d>
for EOF. Is there any way to send a signal likeSIGTERM
orSIGHUP
(perhaps using anix::sys::signal::Signal
) to the underlying process?An alternative might be adding a method to the
PtySession
which gives you a mutable reference to the underlyingPtyProcess
so you can callsignal()
and friends directly on that.