[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
env+nice, one bug fix, two test corrections
From: |
Jim Meyering |
Subject: |
env+nice, one bug fix, two test corrections |
Date: |
Mon, 26 Oct 2009 10:04:57 +0100 |
This first one is a bug fix.
The only difference from the patch I posted Friday
is the addition of a NEWS entry.
The other two patches adjust tests of env and nice.
>From 501bf7b589e8c63c408c86fce5bb9902ae019017 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 24 Oct 2009 13:50:13 +0200
Subject: [PATCH 1/3] 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.
---
NEWS | 4 ++++
src/nice.c | 9 ++++++++-
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/NEWS b/NEWS
index 315ae5f..5399229 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 b04f675..e157db8 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]);
--
1.6.5.1.349.gd3b1e
>From 50e837b1c454e7eb50d0fc67e7f16668b3e288aa Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 24 Oct 2009 13:53:05 +0200
Subject: [PATCH 2/3] tests: nice: adjust new tests to work more portably
* tests/misc/nice (tests): Accommodate a nice program for which
"nice -n -1 nice" prints nothing. It should print -1 or (usually) 0.
Otherwise, we'd get syntax errors.
---
tests/misc/nice | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/misc/nice b/tests/misc/nice
index f271eb4..cf4d96b 100755
--- a/tests/misc/nice
+++ b/tests/misc/nice
@@ -75,7 +75,7 @@ while :; do
done
# Test negative niceness - command must be run whether or not change happens.
-if test `nice -n -1 nice 2> /dev/null` = 0 ; then
+if test x`nice -n -1 nice 2> /dev/null` = x0 ; then
# unprivileged user - warn about failure to change
nice -n -1 true 2> err || fail=1
test -s err || fail=1
@@ -86,8 +86,8 @@ else
# superuser - change succeeds
nice -n -1 nice 2> err || fail=1
test -s err && fail=1
- test `nice -n -1 nice` = -1 || fail=1
- test `nice --1 nice` = -1 || fail=1
+ test x`nice -n -1 nice` = x-1 || fail=1
+ test x`nice --1 nice` = x-1 || fail=1
fi
Exit $fail
--
1.6.5.1.349.gd3b1e
>From d9cf7c911f2d5aba6ae04615d179fb2aaf3f06d9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 25 Oct 2009 16:21:40 +0100
Subject: [PATCH 3/3] tests: adjust new env test not to fail
* tests/misc/env: Create ./-i as a link to our "echo" binary,
rather than as a bourne shell script, so that env can exec it.
Set PATH to ".".
---
tests/misc/env | 12 ++++--------
1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/tests/misc/env b/tests/misc/env
index a3d435b..1e0a22e 100755
--- a/tests/misc/env
+++ b/tests/misc/env
@@ -86,17 +86,13 @@ EOF
compare exp out || fail=1
# Use -- to end arguments.
-cat <<EOF >./-i || framework_failure
-#!/bin/sh
-echo pass
-EOF
-chmod +x ./-i || framework_failure
-case `env -i PATH="$PATH" echo good` in
+ln -s "$abs_top_builddir/src/echo" ./-i || framework_failure
+case `PATH="$PATH:" env -i echo good` in
good) ;;
*) fail=1 ;;
esac
-case `env -- -i PATH="$PATH" echo fail` in
- pass) ;;
+case `env -i -- PATH=. -i no-echo` in
+ no-echo) ;;
*) fail=1 ;;
esac
--
1.6.5.1.349.gd3b1e
- env+nice, one bug fix, two test corrections,
Jim Meyering <=
- Re: env+nice, one bug fix, two test corrections, Eric Blake, 2009/10/26
- Re: env+nice, one bug fix, two test corrections, Eric Blake, 2009/10/26
- Re: env+nice, one bug fix, two test corrections, Jim Meyering, 2009/10/26
- Re: env+nice, one bug fix, two test corrections, Eric Blake, 2009/10/26
- Re: env+nice, one bug fix, two test corrections, Jim Meyering, 2009/10/26
- Re: env+nice, one bug fix, two test corrections, Eric Blake, 2009/10/26
- Re: env+nice, one bug fix, two test corrections, Jim Meyering, 2009/10/27
Re: env+nice, one bug fix, two test corrections, Eric Blake, 2009/10/28