Repository navigation
Do not attempt to take control of terminal in non-interactive mode - #9693
Conversation
|
@IanManske - how do you want to go with this? I've got the revert at #9694 in case we can't come up with a quick fix, but if you think you've got it, we could try your latest changes. |
|
@jntrnr Whoops, forgot to remark this as ready for review. Yes, I think this should work, thanks. |
|
@IanManske - unfortunately this PR doesn't fix the issue. I went ahead and reverted the original fix to give us time to find a better permanent fix. |
|
Wow this is embarrassing, I must have ran the tests in nushell and not bash on my end. Sorry about that! 😓 |
|
Ok, problem was that since we no longer take control of the terminal, we must also not give control of the terminal in non-interactive mode. I ran the tests locally in bash this time 😅, and this seems to fix the issue. I will to continue test for a little longer to make sure. Others might want to confirm that tests work locally in a terminal on macOS, wsl, and windows. In the reference you can see that they first check |
|
I just gave the latest fixes a go, and was able to run a full |
|
Ok, great! |
|
I checked out this PR and ran |
|
Ok, I compared bash's If we add the following lines from the reference to /* Put ourselves in our own process group. */
shell_pgid = getpid ();
if (setpgid (shell_pgid, shell_pgid) < 0)
{
perror ("Couldn't put the shell in its own process group");
exit (1);
}
/* Grab control of the terminal. */
tcsetpgrp (shell_terminal, shell_pgid);Then, we match bash exactly, but I'm not sure if we absolutely need these lines. The PR as is seems to work? Also, this PR partially fixes 9026. (I updated the decription to match.) |
|
I decided to add the lines above, so nushell should match bash's job management. This is excluding signals (out of scope for this PR) and background jobs (which we don't have). However, adding these lines caused an issue with nushell as a login shell where it would fail with Anyways, I think this PR is ready! |
|
let's give this a try and see if it works better than our last several tries. 😆 Thanks for working with us @IanManske! |
|
OK can still get |
|
@sholderbach Shoot, ok. Is it always happening and is it happening on specific test(s)? I've run |
|
I think I may have just reproduces this in WSL with nushell as my login shell. Something odd is going on here when i run I've ran it twice now and it gives the same response after |
|
Ok, issue is |
# Description After #9693, tests will stop and go into the background if run locally in bash, since nushell is being run in interactive mode even though `--testbin` is supplied. This makes nushell run in non-interactive mode if `--testbin` is supplied.
# Description This reverts #9693 as it lead to CPU hangs. (btw, did the revert by hand as it couldn't be done automatically. Hopefully I didn't miss anything 😅 ) Fixes #9859 cc @IanManske # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect -A clippy::result_large_err` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
# Description This reverts nushell#9693 as it lead to CPU hangs. (btw, did the revert by hand as it couldn't be done automatically. Hopefully I didn't miss anything 😅 ) Fixes nushell#9859 cc @IanManske # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect -A clippy::result_large_err` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
# Description Currently, foreground process management is disabled for macOS, since the original code had issues (see #7068). This PR re-enables process management on macOS in combination with the changes from #9693. # User-Facing Changes Fixes hang on exit for nested nushells on macOS (issue #9859). Nushell should now manage processes in the same way on macOS and other unix systems.
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 from #6584:
fishcode also seems to follow this.This partially fixes 9026. That is, nushell will no longer set the foreground process group in non-interactive mode.