Skip to content

Commit

Permalink
Respect current priority Fixes #5365 (#5381)
Browse files Browse the repository at this point in the history
* Respect current priority

This otherwise breaks in linux-like environments when starting MSBuild at below normal priority unless also run with administrator privileges.

Fixes #5365
  • Loading branch information
Forgind committed May 29, 2020
1 parent 5ca6771 commit a936b97
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/MSBuild/XMake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,13 @@ string commandLine
Environment.SetEnvironmentVariable("MSBUILDLOADALLFILESASWRITEABLE", "1");
}

// Honor the low priority flag, we place our selves below normal
// priority and let sub processes inherit that priority.
ProcessPriorityClass priority = lowPriority ? ProcessPriorityClass.BelowNormal : ProcessPriorityClass.Normal;
Process.GetCurrentProcess().PriorityClass = priority;
// Honor the low priority flag, we place our selves below normal priority and let sub processes inherit
// that priority. Idle priority would prevent the build from proceeding as the user does normal actions.
// We avoid increasing priority because that causes failures on mac/linux.
if (lowPriority && Process.GetCurrentProcess().PriorityClass != ProcessPriorityClass.Idle)
{
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
}

DateTime t1 = DateTime.Now;

Expand Down

0 comments on commit a936b97

Please sign in to comment.