// Kill the process
 public void KillProcess()
 {
     KillUtil.KillPid(process.Id);
     Log.Info(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}: ------------------------------------------------------------------", projectName));
     Log.Info(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}: ---------The Build Process was successfully aborted---------------", projectName));
     Log.Info(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}: ------------------------------------------------------------------", projectName));
 }
示例#2
0
 private void Kill(Process process, ProcessInfo processInfo, ProcessReader standardOutput, ProcessReader standardError)
 {
     Log.Warning(string.Format("Process timed out: {0} {1}.  Process id: {2}.  This process will now be killed.", processInfo.FileName, processInfo.Arguments, process.Id));
     Log.Debug(string.Format("Process stdout: {0}", standardOutput.Output));
     Log.Debug(string.Format("Process stderr: {0}", standardError.Output));
     try
     {
         KillUtil.KillPid(process.Id);
         if (!process.WaitForExit(WAIT_FOR_KILLED_PROCESS_TIMEOUT))
         {
             throw new CruiseControlException(string.Format(@"The killed process {0} did not terminate within the allotted timeout period {1}.  The process or one of its child processes may not have died.  This may create problems when trying to re-execute the process.  It may be necessary to reboot the server to recover.", process.Id, WAIT_FOR_KILLED_PROCESS_TIMEOUT));
         }
         Log.Warning(string.Format("The process has been killed: {0}", process.Id));
     }
     catch (InvalidOperationException)
     {
         Log.Warning(string.Format("Process has already exited before getting killed: {0}", process.Id));
     }
     Log.Warning(string.Format("The timed out process has been killed: {0}", process.Id));
 }
            private void Kill()
            {
                const int waitForKilledProcessTimeout = 10000;

                Log.Debug(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Sending kill to process {0} and waiting {1} seconds for it to exit.", process.Id, waitForKilledProcessTimeout / 1000));
                CancelEventsAndWait();
                try
                {
                    KillUtil.KillPid(process.Id);
                    if (!process.WaitForExit(waitForKilledProcessTimeout))
                    {
                        throw new CruiseControlException(
                                  string.Format(CultureInfo.CurrentCulture, @"The killed process {0} did not terminate within the allotted timeout period {1}.  The process or one of its child processes may not have died.  This may create problems when trying to re-execute the process.  It may be necessary to reboot the server to recover.",
                                                process.Id,
                                                waitForKilledProcessTimeout));
                    }
                    Log.Warning(string.Format(System.Globalization.CultureInfo.CurrentCulture, "The process has been killed: {0}", process.Id));
                }
                catch (InvalidOperationException)
                {
                    Log.Warning(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Process has already exited before getting killed: {0}", process.Id));
                }
            }