1- using System ;
1+ #nullable enable
2+
3+ using System ;
24using System . Collections . Generic ;
35using System . Diagnostics ;
46using System . IO . Pipelines ;
57using System . Threading . Tasks ;
68using Flow . Launcher . Infrastructure ;
79using Flow . Launcher . Plugin ;
810using Meziantou . Framework . Win32 ;
11+ using Microsoft . VisualBasic . ApplicationServices ;
912using Nerdbank . Streams ;
1013
1114namespace Flow . Launcher . Core . Plugin
@@ -18,31 +21,37 @@ static ProcessStreamPluginV2()
1821 {
1922 _jobObject . SetLimits ( new JobObjectLimits ( )
2023 {
21- Flags = JobObjectLimitFlags . KillOnJobClose | JobObjectLimitFlags . DieOnUnhandledException
24+ Flags = JobObjectLimitFlags . KillOnJobClose | JobObjectLimitFlags . DieOnUnhandledException |
25+ JobObjectLimitFlags . SilentBreakawayOk
2226 } ) ;
23-
27+
2428 _jobObject . AssignProcess ( Process . GetCurrentProcess ( ) ) ;
2529 }
2630
27- public override string SupportedLanguage { get ; set ; }
28- protected sealed override IDuplexPipe ClientPipe { get ; set ; }
31+ protected sealed override IDuplexPipe ClientPipe { get ; set ; } = null ! ;
2932
3033 protected abstract ProcessStartInfo StartInfo { get ; set ; }
3134
32- protected Process ClientProcess { get ; set ; }
35+ protected Process ClientProcess { get ; set ; } = null ! ;
3336
3437 public override async Task InitAsync ( PluginInitContext context )
3538 {
3639 StartInfo . EnvironmentVariables [ "FLOW_VERSION" ] = Constant . Version ;
3740 StartInfo . EnvironmentVariables [ "FLOW_PROGRAM_DIRECTORY" ] = Constant . ProgramDirectory ;
3841 StartInfo . EnvironmentVariables [ "FLOW_APPLICATION_DIRECTORY" ] = Constant . ApplicationDirectory ;
3942
40- StartInfo . ArgumentList . Add ( context . CurrentPluginMetadata . ExecuteFilePath ) ;
43+ StartInfo . RedirectStandardError = true ;
44+ StartInfo . RedirectStandardInput = true ;
45+ StartInfo . RedirectStandardOutput = true ;
46+ StartInfo . CreateNoWindow = true ;
47+ StartInfo . UseShellExecute = false ;
4148 StartInfo . WorkingDirectory = context . CurrentPluginMetadata . PluginDirectory ;
4249
43- ClientProcess = Process . Start ( StartInfo ) ;
44- ArgumentNullException . ThrowIfNull ( ClientProcess ) ;
45-
50+ var process = Process . Start ( StartInfo ) ;
51+ ArgumentNullException . ThrowIfNull ( process ) ;
52+ ClientProcess = process ;
53+ _jobObject . AssignProcess ( ClientProcess ) ;
54+
4655 SetupPipe ( ClientProcess ) ;
4756
4857 ErrorStream = ClientProcess . StandardError ;
0 commit comments