crossterm icon indicating copy to clipboard operation
crossterm copied to clipboard

something wrong when running inside container

Open vCassius opened this issue 2 years ago • 0 comments

Describe the bug something wrong when running inside container

  • source 1:
    match crossterm::terminal::enable_raw_mode() {
        Ok(_) => {}
        Err(e) => {
            tracing::error!("failed to enable raw mode,err: {e}")
        }
    };
  • exception 1:
End of terminal size stream
thread 'tokio-runtime-worker' panicked at /Users/vincent/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/tokio-1.32.0/src/runtime/task/core.rs:381:22:
JoinHandle polled after completion
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  2023-11-03 09:24:10.662 ERROR v_kubernetes_action::pkg::salvo::router::pod: failed to enable raw mode,err: No such device or address (os error 6)
    at src/pkg/salvo/router/pod.rs:457
  • source 2:
#[cfg(unix)]
// Send the new terminal size to channel when it change
async fn handle_terminal_size(mut channel: Sender<TerminalSize>) -> anyhow::Result<()> {
    let (width, height) = match crossterm::terminal::size() {
        Ok((w, h)) => (w, h),
        Err(e) => {
            let err = format!("fail to cross term terminal size ,err: {e}");
            tracing::error!("fail to cross term terminal size ,err: {err}");
            return Err(anyhow!(err));
        }
    };
    match channel.send(TerminalSize { height, width }).await {
        Ok(_) => {}
        Err(e) => {
            let err = format!("fail to send terminal size to channel,err: {e}");
            tracing::error!(err);
            return Err(anyhow!(err));
        }
    };

    // create a stream to catch SIGWINCH signal
    let mut sig = match signal::unix::signal(signal::unix::SignalKind::window_change()) {
        Ok(s) => s,
        Err(e) => {
            let err = format!("fail to windows change err{e}");
            tracing::error!(err);
            return Err(anyhow!(err));
        }
    };
    loop {
        if (sig.recv().await).is_none() {
            return Ok(());
        }
        let (width, height) = match crossterm::terminal::size() {
            Ok((w, h)) => (w, h),
            Err(e) => {
                let err = format!("fail to cross term terminal size ,err: {e}");
                tracing::error!("fail to cross term terminal size ,err: {err}");
                return Err(anyhow!(err));
            }
        };
        match channel.send(TerminalSize { height, width }).await {
            Ok(_) => {}
            Err(e) => {
                let err = format!("fail to send terminal size to channel,err: {e}");
                tracing::error!(err);
                return Err(anyhow!(err));
            }
        };
    }
}
  • exception 2:
  2023-11-03 14:11:24.853 ERROR v_kubernetes_action::pkg::salvo::router::pod: fail to cross term terminal size ,err: fail to cross term terminal size ,err: Resource temporarily unavailable (os error 11)
    at src/pkg/salvo/router/pod.rs:655

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

OS container: amd64/debian:12.1-slim

vCassius avatar Nov 03 '23 01:11 vCassius