Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #408 #411

Merged
merged 1 commit into from
Apr 25, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/app/FakeLib/ProcessHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let startedProcesses = HashSet()
/// [omit]
let start (proc : Process) =
proc.Start() |> ignore
startedProcesses.Add(proc.ProcessName, proc) |> ignore
startedProcesses.Add(proc.Id, proc.StartTime) |> ignore

/// [omit]
let mutable redirectOutputToTrace = false
Expand Down Expand Up @@ -429,18 +429,22 @@ let killMSBuild() = killProcess "msbuild"
let mutable killCreatedProcesses = true

/// Kills all processes that are created by the FAKE build script unless "donotkill" flag was set.
let killAllCreatedProcesses() =
let killAllCreatedProcesses() =
if not killCreatedProcesses then ()
else
if startedProcesses.Count > 0 then
tracefn "Killing all processes that are created by FAKE and are still running."
for name, proc in startedProcesses do
try
if not proc.HasExited then
for pid, startTime in startedProcesses do
try
let proc = Process.GetProcessById pid

// process IDs may be reused by the operating system so we need
// to make sure the process is indeed the one we started
if proc.StartTime = startTime && not proc.HasExited then
try
logfn "Trying to kill %s" name
logfn "Trying to kill %s" proc.ProcessName
kill proc
with exn -> logfn "Killing %s failed with %s" name exn.Message
with exn -> logfn "Killing %s failed with %s" proc.ProcessName exn.Message
with exn -> ()
startedProcesses.Clear()

Expand Down