summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-10-24 13:50:13 +0200
committerJim Meyering <meyering@redhat.com>2009-10-26 08:25:34 +0100
commit501bf7b589e8c63c408c86fce5bb9902ae019017 (patch)
treebb481650db8dc23e5a0a0bdd528677eb1bec73bd /src
parent69fbfd400c8000e7a7aeed399476c6d9c002a0bc (diff)
downloadcoreutils-501bf7b589e8c63c408c86fce5bb9902ae019017.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/nice.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/nice.c b/src/nice.c
index b04f675fb..e157db801 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]);