Repository navigation
Try again: in unix like system, set foreground process while running external command - #6273
Conversation
|
@WindSoilder looks like your branch is working fine here 🎉 |
|
I tested this too on my mac and couldn't get it to suspend like it was doing. |
|
@jntrnr I requested your review here because you had some way of reproducing some failure with testing. Can you please repeat that on this PR to see if this PR fixes the issues you were seeing? |
|
Testing it out on my machine, it looks like this doesn't crash anymore which is great. I'm trying to get the functionality to work in GNOME Terminal: if I type |
|
@jntrnr I believe updating the title is a separate thing since right now that is done via ansi escape sequences. I thought this was more for the tmux usage. This issue #6156 goes into detail about what the use case is because I kept pushing back on saying that we can just set the title easily before I understood what the goal was. However, we could throw the escape code in there when this happens too, if we wanted to. |
Yeah, and I've checked |
|
@rosshadden can you please test this to make sure it works as described in #6156? |
|
Yeah I'll try when I can. I just cut my thumb and got stitches tonight so it might have to wait a day or so 😅 |
|
A bit late since you merged it a couple hours ago, but I can confirm this works too. Props for getting it working again while fixing the issue that was found with the other approach! |
|
thanks @rosshadden. we appreciate your feedback and testing! |
|
I've come across a bug introduced by this commit (1d18f69). The only way I currently know to reproduce it involves less, e.g. Assuming you don't have a very large screen, that command should leave the less process running. It should exit with (Edited) I'm using |
|
@dandavison How can you tell if it's exiting with SIGINT? or are you just saying it doesn't respond to Ctrl-C? |
|
I'm sorry, my initial report was confused: the bug is actually that it doesn't respond to the For signals, the behavior is the same in bash and zsh and nushell (1d18f69) and so there is no bug relating to the way it handles signals. So the following is all irrelevant but, for the record, on bash, zsh, and nushell, it does not respond to |
|
hmmm, i don't have a problem with less 590 responding to q with your example. |
|
@fdncred, hm, I certainly hope I'm not wasting time here! But I do still think there's a bug somewhere. I just tested on two separate MacOS machines. With a nu binary built on current main (f1d72e2), the bug reproduced on both machines. I tested less 590 and less 600 on one of those machines and it reproduced for both less versions. (Also checked both iTerm2.app and Terminal.app on one of the machines). |
…running external command (nushell#6273)" This reverts commit 1d18f69.
|
I think the missing piece might be not unblocking signals in the forked child ( |
|
@unrelentingtech thanks for looking into this. I haven't experimented with what you said yet. However, the bug seemed to be present in ion also (@WindSoilder and I both observed that I believe). |
|
Looking at fish, here it actually resets signals for the forked child before launch. It's not super obvious at a first glance but it's a |
| } | ||
| } | ||
|
|
||
| // If `prepare_to_foreground` function is not called, the function will fail with silence and do nothing. |
There was a problem hiding this comment.
I'm not sure how that comment is true btw? The check is for stdin being a tty; prepare_to_foreground does not touch stdin at all…
It's set_terminal_leader in the shell initialization that does that.
| } | ||
|
|
||
| // TODO: investigate if we can set foreground process through windows system call. | ||
| #[cfg(target_family = "windows")] |
There was a problem hiding this comment.
The blank impl probably should be cfg(not(unix)) rather than windows specifically…
|
Turns out there's some signal manipulation happening in |
…s while running external command (nushell#6273)" (nushell#6542)" This reverts commit 2bb367f.
…s while running external command (nushell#6273)" (nushell#6542)" This reverts commit 2bb367f.
…s while running external command (nushell#6273)" (nushell#6542)" This reverts commit 2bb367f.
* Revert "Revert "Try again: in unix like system, set foreground process while running external command (#6273)" (#6542)" This reverts commit 2bb367f. * Make foreground job control hopefully work correctly These changes are mostly inspired by the glibc manual. * Fix typo in external command description * Only restore tty control to shell when no fg procs are left; reuse pgrp * Rework terminal acquirement code to be like fish Co-authored-by: Darren Schroeder <[email protected]>


Description
Relative: #6156 #3861 #6240
Check the implementation in ion
I've done running unit testing on unix several times, and done some manual tests, and it works for me.
@herlon214 Would you please check if the build fix the issue #6240 ?
Tests
Make sure you've done the following:
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --checkto check standard code formatting (cargo fmt --allapplies these changes)cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectto check that you're using the standard code stylecargo test --workspace --features=extrato check that all the tests pass