[git commit] chpst: fix error check of nice(2) call

Denys Vlasenko vda.linux at googlemail.com
Mon Dec 9 01:08:52 UTC 2024


commit: https://git.busybox.net/busybox/commit/?id=e6f3a3b381fd32fc711b410aff9c9a37b75d353f
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Check errno instead of return value because -1 is a valid return
value also on success.

Signed-off-by: Christian Franke <christian.franke at t-online.de>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 runit/chpst.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/runit/chpst.c b/runit/chpst.c
index 2be1a5775..4e3d613b7 100644
--- a/runit/chpst.c
+++ b/runit/chpst.c
@@ -466,7 +466,8 @@ int chpst_main(int argc UNUSED_PARAM, char **argv)
 	/* nice should be done before xsetuid */
 	if (opt & OPT_n) {
 		errno = 0;
-		if (nice(xatoi(nicestr)) == -1)
+		nice(xatoi(nicestr));
+		if (errno)
 			bb_simple_perror_msg_and_die("nice");
 	}
 


More information about the busybox-cvs mailing list