]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
nice: execute program even when setpriority fails due to EACCES
authorJim Meyering <meyering@redhat.com>
Sat, 24 Oct 2009 11:50:13 +0000 (13:50 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 26 Oct 2009 07:25:34 +0000 (08:25 +0100)
* src/nice.c (perm_related_errno): New function.
(main): Use it, rather than testing only errno == EPERM.
* NEWS (Bug fixes): Mention it.

NEWS
src/nice.c

diff --git a/NEWS b/NEWS
index 315ae5f6dee83a3a443ce19518017ec42f2996ce..53992299a74c064750e0b65297692128a42cd46a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,10 @@ GNU coreutils NEWS                                    -*- outline -*-
   This also affected sum, sha1sum, sha224sum, sha384sum and sha512sum.
   [the bug dates back to the initial implementation]
 
+  nice -n -1 PROGRAM now runs PROGRAM even when its internal setpriority
+  call fails with errno == EACCES.
+  [the bug dates back to the initial implementation]
+
   stat -f recognizes more file system types: afs, cifs, anon-inode FS,
   btrfs, cgroupfs, cramfs-wend, debugfs, futexfs, hfs, inotifyfs, minux3,
   nilfs, securityfs, selinux, xenfs
index b04f675fbc574865cec76db787d7552391e147d4..e157db80111375532d984bb5ba81f0d8a5c0f17c 100644 (file)
@@ -86,6 +86,12 @@ With no COMMAND, print the current niceness.  Nicenesses range from\n\
   exit (status);
 }
 
+static bool
+perm_related_errno (int err)
+{
+  return err == EACCES || err == EPERM;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -179,7 +185,8 @@ main (int argc, char **argv)
   ok = (setpriority (PRIO_PROCESS, 0, current_niceness + adjustment) == 0);
 #endif
   if (!ok)
-    error (errno == EPERM ? 0 : EXIT_CANCELED, errno, _("cannot set niceness"));
+    error (perm_related_errno (errno) ? 0
+           : EXIT_CANCELED, errno, _("cannot set niceness"));
 
   execvp (argv[i], &argv[i]);