Steve Langasek has proposed merging 
lp:~vorlon/upstart/default-priority-not-always-zero into lp:upstart.

Requested reviews:
  Upstart Reviewers (upstart-reviewers)

For more details, see:
https://code.launchpad.net/~vorlon/upstart/default-priority-not-always-zero/+merge/134799

Upstart doesn't cope well when it can't set the nice level to 0, which may
be the case if the process is non-root and has been niced.  So instead of
using 0 as the default, use the current nice level as the default; this
gives identical results in the common case, and there's really no reason a
non-root upstart should fail if niced.
-- 
https://code.launchpad.net/~vorlon/upstart/default-priority-not-always-zero/+merge/134799
Your team Upstart Reviewers is requested to review the proposed merge of 
lp:~vorlon/upstart/default-priority-not-always-zero into lp:upstart.
=== modified file 'ChangeLog'
--- ChangeLog	2012-11-18 06:56:58 +0000
+++ ChangeLog	2012-11-18 08:00:27 +0000
@@ -2,6 +2,13 @@
 
 	* init/tests/test_job_process.c: fix test which was accidentally
 	  relying on a variable persisting after it's gone out of scope.
+	* init/job_class.[ch]: instead of assuming a fixed value (0) as the
+	  default nice value for job processes, use whatever the nice value
+	  of the current process is.  This will be important later for user
+	  sessions where an entire session may be started with a higher nice
+	  value; and it fixes running the test suite as part of a nice'd
+	  build.
+	* init/tests/test_job_class.c: update test suite to match.
 
 2012-11-17  Steve Langasek  <[email protected]>
 

=== modified file 'init/job_class.c'
--- init/job_class.c	2012-11-14 14:47:19 +0000
+++ init/job_class.c	2012-11-18 08:00:27 +0000
@@ -27,6 +27,8 @@
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
+#include <sys/time.h>
+#include <sys/resource.h>
 
 #include <nih/macros.h>
 #include <nih/alloc.h>
@@ -219,7 +221,7 @@
 	class->console = default_console >= 0 ? default_console : CONSOLE_LOG;
 
 	class->umask = JOB_DEFAULT_UMASK;
-	class->nice = JOB_DEFAULT_NICE;
+	class->nice = getpriority (PRIO_PROCESS, 0);
 	class->oom_score_adj = JOB_DEFAULT_OOM_SCORE_ADJ;
 
 	for (i = 0; i < RLIMIT_NLIMITS; i++)

=== modified file 'init/job_class.h'
--- init/job_class.h	2012-09-24 09:10:05 +0000
+++ init/job_class.h	2012-11-18 08:00:27 +0000
@@ -102,13 +102,6 @@
 #define JOB_DEFAULT_UMASK 022
 
 /**
- * JOB_DEFAULT_NICE:
- *
- * The default nice level for processes.
- **/
-#define JOB_DEFAULT_NICE 0
-
-/**
  * JOB_DEFAULT_OOM_SCORE_ADJ:
  *
  * The default OOM score adjustment for processes.

=== modified file 'init/tests/test_job_class.c'
--- init/tests/test_job_class.c	2011-12-09 15:27:57 +0000
+++ init/tests/test_job_class.c	2012-11-18 08:00:27 +0000
@@ -27,6 +27,8 @@
 #include <sys/wait.h>
 #include <sys/ptrace.h>
 #include <sys/select.h>
+#include <sys/time.h>
+#include <sys/resource.h>
 
 #include <time.h>
 #include <stdio.h>
@@ -131,7 +133,7 @@
 		TEST_EQ (class->console, CONSOLE_LOG);
 
 		TEST_EQ (class->umask, 022);
-		TEST_EQ (class->nice, 0);
+		TEST_EQ (class->nice, getpriority (PRIO_PROCESS, 0));
 		TEST_EQ (class->oom_score_adj, 0);
 
 		for (i = 0; i < RLIMIT_NLIMITS; i++)

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to