git: 0d644b41d6e4 - main - Revert "improve renice user error messages"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 11 Jun 2026 06:00:07 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=0d644b41d6e485a482040c5e249ec12ff305c8a1
commit 0d644b41d6e485a482040c5e249ec12ff305c8a1
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-06-11 05:58:02 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-06-11 05:59:03 +0000
Revert "improve renice user error messages"
This reverts commit 925f53682469ea12c017b48114b16e8f1627fb0b. The tests are wrong,
so I'm reverting and reopening the pull request.
---
usr.bin/renice/renice.c | 31 +++-----------------
usr.bin/renice/tests/renice_test.sh | 57 -------------------------------------
2 files changed, 4 insertions(+), 84 deletions(-)
diff --git a/usr.bin/renice/renice.c b/usr.bin/renice/renice.c
index 240ddf54134c..4931a39c0f67 100644
--- a/usr.bin/renice/renice.c
+++ b/usr.bin/renice/renice.c
@@ -97,7 +97,6 @@ main(int argc, char *argv[])
if ((pwd = getpwnam(*argv)) != NULL)
who = pwd->pw_uid;
else if (getnum("uid", *argv, &who)) {
- warnx("invalid uid: %s", *argv);
errs++;
continue;
} else if (who < 0) {
@@ -107,7 +106,6 @@ main(int argc, char *argv[])
}
} else {
if (getnum("pid", *argv, &who)) {
- warnx("invalid pid: %s", *argv);
errs++;
continue;
}
@@ -128,27 +126,11 @@ static int
donice(int which, int who, int prio, bool incr)
{
int oldprio;
- const char *who_type;
-
- switch (which) {
- case PRIO_PROCESS:
- who_type = "process";
- break;
- case PRIO_PGRP:
- who_type = "process group";
- break;
- case PRIO_USER:
- who_type = "user";
- break;
- default:
- who_type = "unknown";
- break;
- }
errno = 0;
oldprio = getpriority(which, who);
if (oldprio == -1 && errno) {
- warnx("%s %d: getpriority failed", who_type, who);
+ warn("%d: getpriority", who);
return (1);
}
if (incr)
@@ -158,16 +140,11 @@ donice(int which, int who, int prio, bool incr)
if (prio < PRIO_MIN)
prio = PRIO_MIN;
if (setpriority(which, who, prio) < 0) {
- if (errno == EPERM) {
- warnx("Permission denied: cannot set priority for %s %d",
- who_type, who);
- return (1);
- }
- warnx("%s %d: setpriority failed", who_type, who);
+ warn("%d: setpriority", who);
return (1);
}
- fprintf(stderr, "%s %d: old priority %d, new priority %d\n", who_type,
- who, oldprio, prio);
+ fprintf(stderr, "%d: old priority %d, new priority %d\n", who,
+ oldprio, prio);
return (0);
}
diff --git a/usr.bin/renice/tests/renice_test.sh b/usr.bin/renice/tests/renice_test.sh
index 116f1be60fe9..7983eb594716 100755
--- a/usr.bin/renice/tests/renice_test.sh
+++ b/usr.bin/renice/tests/renice_test.sh
@@ -51,50 +51,6 @@ renice_rel_pid_body() {
kill $pid
}
-atf_test_case renice_invalid_priority
-renice_invalid_priority_head() {
- atf_set "descr" "Verify handling of invalid priority values"
-}
-renice_invalid_priority_body() {
- local pid
- sleep 60 &
- pid=$!
-
- # Test out of range priority
- atf_check -s exit:1 -e match:"numeric value out of range" renice 100000 $pid
- atf_check -s exit:1 -e match:"numeric value out of range" renice -100000 $pid
-
- # Test invalid priority format
- atf_check -s exit:1 -e match:"invalid numeric value" renice "abc" $pid
- atf_check -s exit:1 -e match:"invalid numeric value" renice "12.3" $pid
-
- kill $pid
-}
-
-atf_test_case renice_permission_denied
-renice_permission_denied_head() {
- atf_set "descr" "Verify handling of permission denied cases"
-}
-renice_permission_denied_body() {
- local pid
- sleep 60 &
- pid=$!
-
- # Test permission denied with non-root user
- atf_check -s exit:1 -e match:"Permission denied: cannot set priority" renice -n 10 $pid
-
- kill $pid
-}
-
-atf_test_case renice_nonexistent_process
-renice_nonexistent_process_head() {
- atf_set "descr" "Verify handling of non-existent process"
-}
-renice_nonexistent_process_body() {
- # Test with a non-existent PID
- atf_check -s exit:1 -e match:"process 999999 not found" renice 10 999999
-}
-
atf_test_case renice_abs_pgid
renice_abs_pgid_head() {
atf_set "descr" "Set a process group's nice number to an absolute value"
@@ -159,18 +115,6 @@ renice_rel_user_body() {
kill $pid
}
-atf_test_case renice_invalid_user
-renice_invalid_user_head() {
- atf_set "descr" "Verify handling of invalid user names"
-}
-renice_invalid_user_body() {
- # Test with non-existent user name
- atf_check -s exit:1 -e match:"Invalid user name or UID: nonexist" renice 10 -u nonexist
-
- # Test with invalid UID
- atf_check -s exit:1 -e match:"Invalid UID: -1" renice 10 -u -1
-}
-
atf_test_case renice_delim
renice_delim_head() {
atf_set "descr" "Test various delimiter positions"
@@ -225,7 +169,6 @@ atf_init_test_cases() {
atf_add_test_case renice_rel_pgid
atf_add_test_case renice_abs_user
atf_add_test_case renice_rel_user
- atf_add_test_case renice_invalid_user
atf_add_test_case renice_delim
atf_add_test_case renice_incr_noarg
}