Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt before closing window if terminals have running children #6042

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

theIDinside
Copy link

@theIDinside theIDinside commented Oct 22, 2021

On Linux the user is prompted with a message box that
child processes are running and if they want to quit
and thus kill them.

Implemented for:

  • Linux
  • Windows
  • MacOS

I might be able to add Windows on this list, but MacOS users; well they're on their own. There is absolutely no way to do this in a cross platform manner. But it works on Linux. As such the pull requests should be accepted and issue updated with information that it is not implemented for the other platforms.

Additional features that could be implemented;

  • When user clicks a tab to close; ask the same question as when the window is closed. This requires a lot more insight into the Hyper code base however, since when the user clicks the x (close button) on a tab, the tab immediately disappears from the UI before any "on-close" or "exit" handlers are ran, thus it's on the Electron side, so I suppose some middleware has to be set up, to first direct control back to the "app" code of Hyper, and once handled then send back to Electron to remove it from the UI. Or something like that.

The changes are only made to one file; index.ts. A utility closure called sessionHasRunningChildren checks the Session object's pid, to look in the in-memory drive /proc/.../pid/... to see if Linux has any child info of that pid there and handles it accordingly. It's nowhere near as well designed as this on Windows; instead there we have to jump through a lot of hoops, one of which involves spawning a child process that executes PowerShell and runs some commands - or calling WinAPIs through FFI directly, which in and of itself is very unstable. Poor design, but what else is new on Windows?

I commented in the issue thread here some questions, but I get that this feature isn't exactly at the top of the list.

Also, if and when the PR gets accepted could you be so kind to tag the PR as "hacktoberfest-accepted"? It would be very nice of you.

If you, @LabhanshAgrawal for instance, have some ideas on how to solve the tab thing, or where I could do what is needed, I'd gladly add that additional (though unrequested by the issue) feature, but filed under a separate issue if you would be so kind.

On Linux the user is prompted with a message box that
child processes are running and if they want to quit
and thus kill them.
@LabhanshAgrawal
Copy link
Collaborator

Thanks a lot for your contribution
I'm on vacation this week, so will not be able to review just yet. Will get back once I've gone through it.

@LabhanshAgrawal LabhanshAgrawal added the hacktoberfest-accepted HacktoberFest 2021 label label Oct 25, 2021
@LabhanshAgrawal
Copy link
Collaborator

Adding the label now, as it'll take time for review.

@theIDinside
Copy link
Author

Adding the label now, as it'll take time for review.

Thank you! Much appreciated! I'll try and eek out the Windows version of this before the end of October if I can. I think it could possible involve some FFI though, which means it would have to be built during yarn run dev or something like that, which I am completely inexperienced in how to set up. We'll see if I can manage it!

@Giffen-good
Copy link

Hey I could provide the code to run a check for Mac OS. May I checkout your PR and add the condition for MacOS within your sessionHasRunningChildren method?

const opt = dialog.showMessageBoxSync(hwin, {
title: 'Close window & all terminals?',
buttons: ['Close terminal', 'Cancel'],
message: `There is still a process running in a hyper terminal. Closing the terminal will kill it`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
message: `There is still a process running in a hyper terminal. Closing the terminal will kill it`
message: `There is still a process running in a hyper terminal. Closing the terminal will kill it.`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted HacktoberFest 2021 label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants