modules/InstallationSDK.ChefClientInstaller/code/WindowsService.cs
/// <summary>
/// Attempt to kill process. It can ocurr that the process has been killed prior to getting to this statement as the process tree is being killed.
/// </summary>
/// <param name="processId">ID of process to kill.</param>
Attempt to kill process. It can ocurr that the process has been killed prior to getting to this statement as the process tree is being killed.
Attempt to kill process . It can ocurr that the process has been killed prior to getting to this statement as the process tree is being killed .
private void KillProcess(uint processId)
        {
            try
            {
                if ((int)processId != Process.GetCurrentProcess().Id)
                {
                    var process = Process.GetProcessById((int)processId);
                    Trace.TraceInformation("{0} - Killing process [{1}] with Id [{2}]", Name, process.ProcessName, processId);
                    process.Kill();
                }
            }
            catch (ArgumentException e)
            {
                Trace.TraceInformation("{0} - failed to find process [{1}]. Process already killed. Ex:{2}", Name, processId, e.ToString());
            }
            catch (System.ComponentModel.Win32Exception e)
            {
                Trace.TraceInformation("{0} - failed to kill process [{1}]. Ex:{2}", Name, processId, e.ToString());
            }
        }
private void KillProcess ( uint processId ) { try { if ( ( int ) processId != Process . GetCurrentProcess ( ) . Id ) { var process = Process . GetProcessById ( ( int ) processId ) ; Trace . TraceInformation ( " " , Name , process . ProcessName , processId ) ; process . Kill ( ) ; } } catch ( ArgumentException e ) { Trace . TraceInformation ( " " , Name , processId , e . ToString ( ) ) ; } catch ( System . ComponentModel . Win32Exception e ) { Trace . TraceInformation ( " " , Name , processId , e . ToString ( ) ) ; } }
Attempt to kill process.
Attempt to kill process .
processId
uint
ID of process to kill.
ID of process to kill .