[PATCH 01/15] renice: exit with non-zero value when arguments cause warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This commit also fixes potential error counter wrap, which theoretically
could make command to exit with a success when it internally failed just
correct amount of times.

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 sys-utils/renice.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys-utils/renice.c b/sys-utils/renice.c
index 50b1642..c0378e1 100644
--- a/sys-utils/renice.c
+++ b/sys-utils/renice.c
@@ -138,6 +138,7 @@ main(int argc, char **argv)
 
 			if (pwd == NULL) {
 				warnx(_("unknown user %s"), *argv);
+				errs = 1;
 				continue;
 			}
 			who = pwd->pw_uid;
@@ -145,10 +146,11 @@ main(int argc, char **argv)
 			who = strtol(*argv, &endptr, 10);
 			if (who < 0 || *endptr) {
 				warnx(_("bad value %s"), *argv);
+				errs = 1;
 				continue;
 			}
 		}
-		errs += donice(which, who, prio);
+		errs |= donice(which, who, prio);
 	}
 	return errs != 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux