Fetching contributors…
Cannot retrieve contributors at this time
52 lines (43 sloc) 2.19 KB

Runaway Process Killer Extension

In particular cases Windows service wrapper may leak the process after the service completion. It happens when WinSW gets terminated without executing the shutdown logic. Examples: force kill of the service process, .NET Runtime crash, missing permissions to kill processes or a bug in the logic.

Such runaway processes may conflict with the service process once it restarts. This extension allows preventing it by running the runaway process termination on startup before the executable gets started.

Since: WinSW 2.0.


The extension can be configured via the XML Configuration File. Configuration sample:

<?xml version="1.0" encoding="utf-8" ?>
  <name>Sample service</name>
  <description>This is a stub service.</description>

	<!-- This is a sample configuration for the RunawayProcessKiller extension. -->
  <extension enabled="true" 
      <!-- Absolute path to the PID file, which stores ID of the previously launched process. -->
      <!-- Defines the process termination timeout in milliseconds. 
           This timeout will be applied multiple times for each child process.
           After the timeout WinSW will try to force kill the process.
      <!-- If true, the parent process will be terminated first if the runaway process gets terminated. -->


  • The current implementation of the the extension checks only the root process (started executable)
  • If the runaway process is detected the entire, the entire process tree gets terminated
  • WinSW gives the runaway process a chance to the gracefully terminate. If it does not do it within the timeout, the process will be force-killed.
  • If the force kill fails, the WinSW startup continues with a warning.