-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Fix unified_exec on windows #7620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
1ddd645
281dbd2
8e060dc
b7a2d79
8c642a1
6c7f65a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| use core::fmt; | ||
| use std::collections::HashMap; | ||
| use std::io::ErrorKind; | ||
| use std::path::Path; | ||
|
|
@@ -9,13 +10,17 @@ use std::time::Duration; | |
| use anyhow::Result; | ||
| use portable_pty::native_pty_system; | ||
| use portable_pty::CommandBuilder; | ||
| use portable_pty::PtyPair; | ||
| use portable_pty::PtySize; | ||
| use tokio::sync::broadcast; | ||
| use tokio::sync::mpsc; | ||
| use tokio::sync::oneshot; | ||
| use tokio::sync::Mutex as TokioMutex; | ||
| use tokio::task::JoinHandle; | ||
|
|
||
| #[allow(dead_code)] | ||
|
||
| struct PtyPairWrapper(PtyPair); | ||
|
|
||
| #[derive(Debug)] | ||
| pub struct ExecCommandSession { | ||
| writer_tx: mpsc::Sender<Vec<u8>>, | ||
|
|
@@ -26,6 +31,15 @@ pub struct ExecCommandSession { | |
| wait_handle: StdMutex<Option<JoinHandle<()>>>, | ||
| exit_status: Arc<AtomicBool>, | ||
| exit_code: Arc<StdMutex<Option<i32>>>, | ||
| // PtyPair must be preserved because the process will receive Control+C if the | ||
| // slave is closed | ||
| _pair: StdMutex<PtyPairWrapper>, | ||
| } | ||
|
|
||
| impl fmt::Debug for PtyPairWrapper { | ||
| fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| impl ExecCommandSession { | ||
|
|
@@ -39,6 +53,7 @@ impl ExecCommandSession { | |
| wait_handle: JoinHandle<()>, | ||
| exit_status: Arc<AtomicBool>, | ||
| exit_code: Arc<StdMutex<Option<i32>>>, | ||
| pair: PtyPair, | ||
| ) -> (Self, broadcast::Receiver<Vec<u8>>) { | ||
| let initial_output_rx = output_tx.subscribe(); | ||
| ( | ||
|
|
@@ -51,6 +66,7 @@ impl ExecCommandSession { | |
| wait_handle: StdMutex::new(Some(wait_handle)), | ||
| exit_status, | ||
| exit_code, | ||
| _pair: StdMutex::new(PtyPairWrapper(pair)), | ||
| }, | ||
| initial_output_rx, | ||
| ) | ||
|
|
@@ -201,6 +217,7 @@ pub async fn spawn_pty_process( | |
| wait_handle, | ||
| exit_status, | ||
| exit_code, | ||
| pair, | ||
| ); | ||
|
|
||
| Ok(SpawnedPty { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why skipping windows on this one?