[jhbuild] terminal: Avoid passing invalid arguments if ionice/chrt are too old
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild] terminal: Avoid passing invalid arguments if ionice/chrt are too old
- Date: Wed, 7 Mar 2012 14:47:33 +0000 (UTC)
commit aac1075a6ccddd92241c044db87b684da0469d35
Author: Colin Walters <walters verbum org>
Date: Thu Mar 1 15:28:46 2012 -0500
terminal: Avoid passing invalid arguments if ionice/chrt are too old
https://bugzilla.gnome.org/show_bug.cgi?id=671162
jhbuild/frontends/buildscript.py | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/jhbuild/frontends/buildscript.py b/jhbuild/frontends/buildscript.py
index 66570d3..d4e9845 100644
--- a/jhbuild/frontends/buildscript.py
+++ b/jhbuild/frontends/buildscript.py
@@ -20,6 +20,7 @@
import os
import logging
+import subprocess
from jhbuild.utils import trigger
from jhbuild.utils import cmds
@@ -60,13 +61,22 @@ class BuildScript:
self.subprocess_nice_args = []
if config.nice_build:
- if cmds.has_command('chrt'):
- self.subprocess_nice_args.extend(['chrt', '--idle', '0'])
+ chrt_args = ['chrt', '--idle', '0']
+ devnull = open(os.devnull, 'w')
+ if (cmds.has_command('chrt') and
+ subprocess.call(chrt_args + ['true'], stdout=devnull, stderr=devnull) == 0):
+ self.subprocess_nice_args.extend(chrt_args)
+
elif cmds.has_command('nice'):
self.subprocess_nice_args.append('nice')
+ ionice_args = ['ionice', '-c', '3', '-t']
if cmds.has_command('ionice'):
- self.subprocess_nice_args.extend(['ionice', '-c', '3', '-t'])
+ subproc = subprocess.Popen(ionice_args + ['true'], stdout=devnull,
+ stderr=subprocess.PIPE)
+ stderr_val = subproc.communicate()[1]
+ if subproc.returncode == 0 and len(stderr_val) == 0:
+ self.subprocess_nice_args.extend(ionice_args)
def _prepare_execute(self, command):
if self.subprocess_nice_args:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]