Apply patch from Felipe Kellermann to simlify logic of sort functions.
[oweals/busybox.git] / procps / renice.c
index af7ce94ca9713974f4eb99d4e30fae1a13d74125..a6f0820dfc8770c3ef0282ab86357747c5b3b18e 100644 (file)
  *
  */
 
-#include "internal.h"
 #include <stdio.h>
 #include <errno.h>
+#include <stdlib.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include "busybox.h"
 
 
 extern int renice_main(int argc, char **argv)
 {
-       int prio, err = 0;
-       
-       if (argc < 3)   usage(renice_usage);
-               
+       int prio, status = EXIT_SUCCESS;
+
+       if (argc < 3)   bb_show_usage();
+
        prio = atoi(*++argv);
        if (prio > 20)          prio = 20;
        if (prio < -20)         prio = -20;
-       
+
        while (*++argv) {
                int ps = atoi(*argv);
                int oldp = getpriority(PRIO_PROCESS, ps);
-               
+
                if (setpriority(PRIO_PROCESS, ps, prio) == 0) {
                        printf("%d: old priority %d, new priority %d\n", ps, oldp, prio );
                } else {
-                       fprintf(stderr, "renice: %d: setpriority: ", ps);
-                       perror("");
-                       err = 1;
+                       bb_perror_msg("%d: setpriority", ps);
+                       status = EXIT_FAILURE;
                }
        }
-       exit(err);
+
+       return status;
 }