File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -180,7 +180,24 @@ public void OpenWithDefaultEditor(string file)
180180 public void TerminateProcess ( Process proc )
181181 {
182182 if ( kill ( - proc . Id , 15 ) != 0 )
183- proc . Kill ( true ) ; // Fallback to force kill if the process is not terminated by SIGTERM
183+ {
184+ // If the process already exited, we can just ignore the error.
185+ if ( Marshal . GetLastPInvokeError ( ) == 3 /* ESRCH */ )
186+ return ;
187+
188+ // Actually, this will not be called since the process is
189+ // spawned by us (EPERM will not happen), and SIGTERM (15)
190+ // is a valid signal (EINVAL will not happen).
191+ // See https://www.man7.org/linux/man-pages/man2/kill.2.html
192+ try
193+ {
194+ proc . Kill ( true ) ;
195+ }
196+ catch
197+ {
198+ // Ignore any errors when trying to kill the process
199+ }
200+ }
184201 }
185202
186203 private string FindExecutable ( string filename )
You can’t perform that action at this time.
0 commit comments