helix icon indicating copy to clipboard operation
helix copied to clipboard

Respect SIG_IGN for SIGTSTP

Open AlexanderBrevig opened this issue 3 years ago • 7 comments

This implementation is probably ugly.

Any pointers to make it cleaner is much appreciated!

It works, tested with elvish, bash, zsh and sh. It correctly disables C-z for elvish but not the others.

Fixes #3321

AlexanderBrevig avatar Aug 03 '22 19:08 AlexanderBrevig

Ready for your wise eyes again @the-mikedavis (tests and lints pass now)

AlexanderBrevig avatar Aug 04 '22 09:08 AlexanderBrevig

Looking at this now, I think an AtomicBool would be simpler than a OnceCell. You can use Ordering::Relaxed everywhere since we don't care about race conditions of changes between threads.

The alternative way to do this without using shared memory would be to pass whether or not suspension is allowed through from Application to helix_view::editor::Editor. That might be even cleaner. Then you would check in suspend

if cx.editor.a_new_field_that_says_whether_or_not_we_can_suspend {
    // send SIG_TSTP
}

the-mikedavis avatar Aug 05 '22 00:08 the-mikedavis

Oh actually, since Editor is created before the Application, you can figure out whether sigtstp is enabled higher up in Application::new before Editor::new is called and pass the bool to Editor::new. No need to use an AtomicBool with this approach, you can just put a new pub suspend_enabled: bool on the helix_view::editor::Editor type.

the-mikedavis avatar Aug 05 '22 12:08 the-mikedavis

Thanks for all the amazing feedback @the-mikedavis! I think all of them are in now.

Looking forward to hopefully get this merged so I can get back to master :)

AlexanderBrevig avatar Aug 05 '22 16:08 AlexanderBrevig

@AlexanderBrevig It looks like there may need to be some conditional compilation. I don't think Windows has typical signals.

AceofSpades5757 avatar Aug 06 '22 01:08 AceofSpades5757

Alright, one last nit from me 😅

In some places we have enable_suspend and in other suspend_enabled. Since there isn't anything to do in order to enable suspending I think we should just use suspend_enabled

the-mikedavis avatar Aug 07 '22 00:08 the-mikedavis

Alright, one last nit from me sweat_smile

In some places we have enable_suspend and in other suspend_enabled. Since there isn't anything to do in order to enable suspending I think we should just use suspend_enabled

I love your feedback and nits :) Absolutely prefer that name myself, I think it's a remnant from the private AtomicBool with get/set-like public API.

It's all much cleaner now, thanks to you 👍🏻

AlexanderBrevig avatar Aug 07 '22 00:08 AlexanderBrevig