about summary refs log tree commit diff
path: root/src/bootstrap/lib.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-05-20 20:55:52 +0000
committerbors <bors@rust-lang.org>2017-05-20 20:55:52 +0000
commit01951a61a49dca35747dc9ba03e5536f337de239 (patch)
tree6aafa8ab9a72283d05b5be67208d245e6f9c3139 /src/bootstrap/lib.rs
parent1cda810970186cf01a8134db53b13f8177cc56ab (diff)
parentdd0855d44b61a979983ae329eb84d1928b5f7eb7 (diff)
downloadrust-01951a61a49dca35747dc9ba03e5536f337de239.tar.gz
rust-01951a61a49dca35747dc9ba03e5536f337de239.zip
Auto merge of #42069 - QuietMisdreavus:low_pri, r=alexchrichton
Add an option to run rustbuild on low priority on Windows and Unix

This is a resurrection of #40776, combining their Windows setup with an additional setup on Unix to set the program group's *nice*ness to +10 (low-but-not-lowest priority, mirroring the priority in the Windows setup) when the `low_priority` option is on.
Diffstat (limited to 'src/bootstrap/lib.rs')
-rw-r--r--src/bootstrap/lib.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index ca9de43f542..7eccc2a49c0 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -76,6 +76,9 @@ extern crate num_cpus;
 extern crate rustc_serialize;
 extern crate toml;
 
+#[cfg(unix)]
+extern crate libc;
+
 use std::cmp;
 use std::collections::HashMap;
 use std::env;
@@ -108,9 +111,21 @@ pub mod util;
 #[cfg(windows)]
 mod job;
 
-#[cfg(not(windows))]
+#[cfg(unix)]
+mod job {
+    use libc;
+
+    pub unsafe fn setup(build: &mut ::Build) {
+        if build.config.low_priority {
+            libc::setpriority(libc::PRIO_PGRP as _, 0, 10);
+        }
+    }
+}
+
+#[cfg(not(any(unix, windows)))]
 mod job {
-    pub unsafe fn setup() {}
+    pub unsafe fn setup(_build: &mut ::Build) {
+    }
 }
 
 pub use config::Config;
@@ -263,7 +278,7 @@ impl Build {
     /// Executes the entire build, as configured by the flags and configuration.
     pub fn build(&mut self) {
         unsafe {
-            job::setup();
+            job::setup(self);
         }
 
         if let Subcommand::Clean = self.flags.cmd {