nuta / nsh

A command-line shell like fish, but POSIX compatible.
906 stars 34 forks source link

Crash on ls #20

Open mathomp4 opened 2 years ago

mathomp4 commented 2 years ago

So, this is probably user error, but it told me to report this and I will.

I saw nsh was in brew and I'm always up for trying new shells (including nushell. So I brew install nsh, ran nsh from my usual zsh and then when I run ls, it lists files and then:

nsh: panicked at 'failed to tcsetpgrp: EINVAL', src/process.rs:193:24
nsh:    0:        0x10e69039b - backtrace::capture::Backtrace::new::h94e01dcc48b96db5
   1:        0x10e65699f - nsh::main::{{closure}}::h041e738f2aeec958
   2:        0x10e708492 - std::panicking::rust_panic_with_hook::h32f3432eccbbcf03
   3:        0x10e70f00a - std::panicking::begin_panic_handler::{{closure}}::heec496a5329a15c8
   4:        0x10e70ef78 - std::sys_common::backtrace::__rust_end_short_backtrace::h9ba91ee04b4386bb
   5:        0x10e707e60 - _rust_begin_unwind
   6:        0x10e73e5cf - core::panicking::panic_fmt::h2b293e6c03a76160
   7:        0x10e73ec65 - core::result::unwrap_failed::hed5438487a4f03df
   8:        0x10e6487f8 - nsh::process::run_in_foreground::hb1058e5c4336dabf
   9:        0x10e6164cc - nsh::eval::run_terms::h94c52fd4b9b5a554
  10:        0x10e64fd28 - nsh::shell::Shell::run_str::h56b5f07065e1fbf4
  11:        0x10e626029 - nsh::mainloop::Mainloop::handle_key_event::hbe974f26d5dfc811
  12:        0x10e623cef - nsh::mainloop::Mainloop::handle_event::hcba2b4fd18674129
  13:        0x10e6203df - nsh::mainloop::Mainloop::run::h0669bafc547fbc4e
  14:        0x10e6537bf - nsh::shell_main::h70b80c33723cca7e
  15:        0x10e6563bc - nsh::main::ha6ee95719b18a463
  16:        0x10e5bf87a - std::sys_common::backtrace::__rust_begin_short_backtrace::hb608f8487b3c3a45
  17:        0x10e671716 - _main

nsh: Something went wrong. Check out ~/.nsh.log and please file this bug on GitHub: https://github.com/nuta/nsh/issues

I broke things! :smile:

nuta commented 2 years ago

Good catch! I'll have look at it later :)

mathomp4 commented 2 years ago

Note that my home laptop where I tried this is a fun melange of randomness. If nsh somehow sees my zsh configuration, I can see all sorts of issues possible. :)

nuta commented 2 years ago

According to the man page, tcsetpgrp(2) returns EINVAL if it's input value is invalid. I think you discovered a corner case in process management which nsh doesn't handle properly.