PowerShell / PowerShell/PowerShellEditorServices

Close stray process when stdio pipe is closed or possibly when parent process is killed (daemon flag?)

Open
#924 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Tasks Issue-Bug
Dominant language
C#
Stars
767
Forks
266
Avg merge
3d 16h
Merged PRs (30d)
1

Description

This is continuation of the effort from:

  1. Issue https://github.com/PowerShell/PowerShellEditorServices/issues/655 PSES needs to shutdown itself when it's supposed to
  2. PR https://github.com/PowerShell/PowerShellEditorServices/pull/663 Close stray processes on exit

#655 was closed by @TylerLeonhardt as it was satisfied by PR #663. However I still believe we can easily get into the situation when LSP text editor that launches PSES gets killed and orphans the PSES process, that keeps running without a purpose. Actually this is the case with Sublime Text and LSP plugin, where other language LSP providers shutdown themselves when the Sublime Text quits without a need to use exit or any other means.

Therefore I propose 2 options for consideration (alternatives):

  1. Introduce new -daemon flag, that unless specified, makes PSES to shutdown itself when the parent process disappears. This will make PSES behave like most of the command line tools, i.e. shutdown itself when the shell or launching process quits.

    The only purpose for PSES to run despite of parent process being alive or not is when it is it intended to be ran as a daemon, and I believe this intent should not be default (as it is now).

  2. Shutdown itself when running as -stdio and when pipe is closed, as I was commenting in other ticket, there is no point running when pipe is closes, because there is nobody that will be able to issue exit and any other command anyways.

Thank you in advance for considering my suggestion. If you prefer I can try to get this behavior adapter myself and send the PR, but you (maintainers) may come to more elegant solution much quicker than me, therefore I post this issue first.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review issue #655 and PR #663 first, then trace the PSES entry points for the -stdio mode and the proposed -daemon flag. Decide which shutdown behavior is intended when the parent disappears or the stdio pipe closes; done means stray PSES processes no longer remain in the covered scenario without breaking daemon use.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.