Show More
@@ -83,5 +83,6 b' async fn run(umask: u32) -> io::Result<i' | |||||
83 | .run_command_chg(&mut handler, env::args_os().skip(1)) |
|
83 | .run_command_chg(&mut handler, env::args_os().skip(1)) | |
84 | .await?; |
|
84 | .await?; | |
85 | procutil::restore_signal_handler_once()?; |
|
85 | procutil::restore_signal_handler_once()?; | |
|
86 | handler.wait_pager().await?; | |||
86 | Ok(code) |
|
87 | Ok(code) | |
87 | } |
|
88 | } |
@@ -9,7 +9,7 b' use std::os::unix::io::AsRawFd;' | |||||
9 | use std::os::unix::process::ExitStatusExt; |
|
9 | use std::os::unix::process::ExitStatusExt; | |
10 | use std::process::Stdio; |
|
10 | use std::process::Stdio; | |
11 | use tokio; |
|
11 | use tokio; | |
12 | use tokio::process::{ChildStdin, Command}; |
|
12 | use tokio::process::{Child, ChildStdin, Command}; | |
13 |
|
13 | |||
14 | use crate::message::CommandSpec; |
|
14 | use crate::message::CommandSpec; | |
15 | use crate::procutil; |
|
15 | use crate::procutil; | |
@@ -31,11 +31,21 b' pub trait SystemHandler {' | |||||
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | /// Default cHg implementation to process requests received from server. |
|
33 | /// Default cHg implementation to process requests received from server. | |
34 |
pub struct ChgUiHandler { |
|
34 | pub struct ChgUiHandler { | |
|
35 | pager: Option<Child>, | |||
|
36 | } | |||
35 |
|
37 | |||
36 | impl ChgUiHandler { |
|
38 | impl ChgUiHandler { | |
37 | pub fn new() -> ChgUiHandler { |
|
39 | pub fn new() -> ChgUiHandler { | |
38 | ChgUiHandler {} |
|
40 | ChgUiHandler { pager: None } | |
|
41 | } | |||
|
42 | ||||
|
43 | /// Waits until the pager process exits. | |||
|
44 | pub async fn wait_pager(&mut self) -> io::Result<()> { | |||
|
45 | if let Some(p) = self.pager.take() { | |||
|
46 | p.await?; | |||
|
47 | } | |||
|
48 | Ok(()) | |||
39 | } |
|
49 | } | |
40 | } |
|
50 | } | |
41 |
|
51 | |||
@@ -51,7 +61,7 b' impl SystemHandler for ChgUiHandler {' | |||||
51 | // otherwise the server won't get SIGPIPE if it does not write |
|
61 | // otherwise the server won't get SIGPIPE if it does not write | |
52 | // anything. (issue5278) |
|
62 | // anything. (issue5278) | |
53 | // kill(peerpid, SIGPIPE); |
|
63 | // kill(peerpid, SIGPIPE); | |
54 | tokio::spawn(async { pager.await }); // just ignore errors |
|
64 | self.pager = Some(pager); | |
55 | Ok(pin) |
|
65 | Ok(pin) | |
56 | } |
|
66 | } | |
57 |
|
67 |
General Comments 0
You need to be logged in to leave comments.
Login now