Skip to content

Fix SIGTTIN handling - #9681

Merged
sophiajt merged 1 commit into
nushell:mainfrom
IanManske:sigttin-fix
Jul 14, 2023
Merged

sophiajt merged 1 commit into
nushell:mainfrom
IanManske:sigttin-fix

Conversation

@IanManske

Copy link
Copy Markdown
Member

Description

Due to a typo? in the reference used to implement SIGTTIN handling, nushell will crash when being sent to the background from within another shell.

For example, currently in bash:

$ nu -n &
[1] 176058
$ ERROR: failed to SIGTTIN ourselves

[1]+  Exit 1                  nu -n
$

Now fixed:

$ nu -n &
[1] 178788
$ jobs
[1]+  Stopped                 nu -n
$

For further reference, this is how fish does it.

User-Facing Changes

Bug fix only -- users should now be able to send nushell to the background.

@WindSoilder

Copy link
Copy Markdown
Contributor

Thanks! I think it'd allow users to debug in vscode, I remember @fdncred faced the issue before, it's really annoying

@fdncred

fdncred commented Jul 14, 2023

Copy link
Copy Markdown
Contributor

Ya, and @sholderbach too. He has an issue open on it somewhere I think. It would be nice if it fixed that problem too.

@IanManske

Copy link
Copy Markdown
Member Author

Oh yeah, issue #6788. Unfortunately, I don't think this fixes that. A temporary solution would be to disable some lines for debug builds. I made another comment on there.

@sophiajt

Copy link
Copy Markdown
Contributor

Thanks!

@sophiajt
sophiajt merged commit 2fc9506 into nushell:main Jul 14, 2023
@sholderbach

Copy link
Copy Markdown
Member

This somehow causes the test binaries to stop: Launching the latest main (53ae03bd) with cargo test --workspace from bash in WSL2/Ubuntu.

test tests::test_cell_path::record_with_nested_list_column_failure ... ok
test tests::test_cell_path::list_row_optional_access_succeeds ... ok
test tests::test_conditionals::if_cond ... ok
test tests::test_commandline::commandline_test_replace ... ok
test tests::test_converters::to_json_escaped ... ok
test tests::test_converters::from_json_2 ... ok
test tests::test_converters::to_json_raw_flag_2 ... ok
test tests::test_converters::to_json_raw_flag_3 ... ok
test tests::test_converters::to_json_raw_flag_1 ... ok
test tests::test_custom_commands::allow_missing_optional_params ... ok
test tests::test_custom_commands::custom_rest_var ... ok

[1]+  Stopped                 cargo test --workspace

And after reviving things with fg things seem to stall again.

test tests::test_stdlib::library_loaded ... ok

test result: ok. 503 passed; 0 failed; 4 ignored; 0 measured; 0 filtered out; finished in 245.55s

     Running tests/main.rs (target/debug/deps/main-a563851cb5fe7f80)

running 438 tests
test const_::const_list ... ok
test const_::const_in_scope ... ok
test const_::const_string ... ok
test const_::const_datetime ... ok
test const_::const_table ... ok
test const_::const_int ... ok
test const_::const_nothing ... ok
test eval::source_file_relative_to_file ... ok
test const_::const_record ... ok
test const_::const_binary ... ok

[1]+  Stopped                 cargo test --workspace

@IanManske

Copy link
Copy Markdown
Member Author

Yep, sorry about that!
Looking over the reference linked above, I don't think we should even be running take_control() if interactive if false.
It seems like previously killpg either did nothing or was erroring, but since interactive was false, no errors were being thrown.

sophiajt added a commit that referenced this pull request Jul 15, 2023
sophiajt added a commit that referenced this pull request Jul 15, 2023
Reverts #9681

As mentioned in #9681 - this breaks running tests in wsl2.
fdncred pushed a commit that referenced this pull request Jul 17, 2023
…9693)

# Description
Fixes a regression from #9681 where nushell will attempt to place itself
into the background or take control of the terminal even in
non-interactive mode.

Using the same
[reference](https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html)
from #6584:

>A subshell that runs *interactively* has to ensure that it has been
placed in the foreground...

>A subshell that runs *non-interactively* cannot and should not support
job control.

`fish`
[code](https://github.com/fish-shell/fish-shell/blob/54fa1ad6ec7adb0d9c14076843ef5e51c18ecc7a/src/reader.cpp#L4862)
also seems to follow this.

This *partially* fixes
[9026](#9026). That is, nushell
will no longer set the foreground process group in non-interactive mode.
@IanManske
IanManske deleted the sigttin-fix branch July 18, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants