From: Jim Meyering Date: Sat, 24 Oct 2009 11:50:13 +0000 (+0200) Subject: nice: execute program even when setpriority fails due to EACCES X-Git-Tag: v8.1~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=501bf7b589e8c63c408c86fce5bb9902ae019017;p=thirdparty%2Fcoreutils.git nice: execute program even when setpriority fails due to EACCES * src/nice.c (perm_related_errno): New function. (main): Use it, rather than testing only errno == EPERM. * NEWS (Bug fixes): Mention it. --- diff --git a/NEWS b/NEWS index 315ae5f6de..53992299a7 100644 --- 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 diff --git a/src/nice.c b/src/nice.c index b04f675fbc..e157db8011 100644 --- a/src/nice.c +++ b/src/nice.c @@ -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]);